Topic: Material Select Searchable Add Searched Term
ilivingston pro premium asked 6 years ago
//MDB MaterialSelect add non-existing items shim... $(document.body).on('click', 'button.mdb-select-add-btn', function () { var searchInput = $(this).parent().find('input.search'); var searchValue = searchInput.val(); var matsel = $('#useApplicationPicker'); matsel.material_select('destroy'); $('option:selected', matsel).removeAttr('selected'); matsel.append('<option value="$NVCREATED$_' + searchValue + '" selected>' + searchValue + '</option>'); matsel.material_select(); });To get my button with the class "mdb-select-add-btn", I updated the MDB.js and MDB.min.js files with: LINE: 20678 FROM:
this.$searchInput = $('<span class="search-wrap ml-2"> <div class="md-form mt-0"> <input type="text" class="search form-control w-100 d-block" placeholder="' + placeholder + '"></div></span>');TO:
this.$searchInput = $('<span class="search-wrap ml-2"> <div class="md-form mt-0"> <input type="text" class="search form-control w-75 d-inline-block" placeholder="' + placeholder + '"> <button type="button" class="mdb-select-add-btn btn btn-sm btn-default">add</button></div></span>');I will have to handle the provided values, but that won't be a big deal.
Sebastian Kaczmarek staff pro premium answered 6 years ago
.material_select
syntax has been replaced by the new .materialSelect
. The old one is still working but it will be removed soon. FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- User: Pro
- Premium support: No
- Technology: MDB jQuery
- MDB Version: 4.5.10
- Device: Computer
- Browser: Latest Firefox
- OS: W10
- Provided sample code: No
- Provided link: No