Topic: Sorting For materialSelect
Hey Guys.
Ok so I have a material select which is populated at run time using jquery, ajax and then reinitializing the materialSelect.
An example of the js output is {"2":"Abuse Of Power","1":"Time Related Offences"} but as soon as jquery inserts it using the code below the sorting is thrown out, and it sorts according to key, not value... How can I sort these options by alphabetical order?
Jquery:
$.each(data, function(key,value) {
$("#offence_cetegory").append($("<option></option>").attr("value",
key).text(value));
});
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Status
Open
Specification of the issue
- User: Free
- Premium support: No
- Technology: MDB jQuery
- MDB Version: 4.14.0
- Device: Laravel
- Browser: Chrome
- OS: Windows
- Provided sample code: No
- Provided link: No
Tags
Related topics
Grzegorz Bujański staff commented 5 years ago
Hi. Please create snippet here: https://mdbootstrap.com/snippets/ i will look at this.