Closed trevornagy closed 9 years ago
I'm currently attempting to load this json into selectize:
{"platforms": [{"id":32,"name":"Sega Saturn","slug":"saturn"}, {"id":14,"name":"Mac","slug":"mac"}, {"id":47,"name":"Virtual Console (Nintendo)","slug":"vc"}, {"id":34,"name":"Android","slug":"android"}, {"id":84,"name":"SG-1000","slug":"sg1000"}, {"id":58,"name":"Super Famicom","slug":"sfam"}, {"id":82,"name":"Web browser","slug":"browser"}] }
I have this code, which isn't working, could anyone give me some suggestions?
var data = JSON.parse('{"platforms":[{"id":32,"name":"Sega Saturn","slug":"saturn"},{"id":14,"name":"Mac","slug":"mac"},{"id":47,"name":"Virtual Console (Nintendo)","slug":"vc"},{"id":34,"name":"Android","slug":"android"},{"id":84,"name":"SG-1000","slug":"sg1000"},{"id":58,"name":"Super Famicom","slug":"sfam"},{"id":82,"name":"Web browser","slug":"browser"}]}'); var options = []; $.each(data.platforms, function() { options.push({ id: this.id, title: this.name, url: "hhtp://site.com/"+this.slug }); }); var $select = $('#select-tools').selectize({ maxItems: null, valueField: 'id', labelField: 'title', searchField: 'title', options: options, create: false });
I'm basing it off of this example, and this one too. What am I doing incorrectly?
I fixed it, the Javascript was correct. My HTML wasn't.
I'm currently attempting to load this json into selectize:
I have this code, which isn't working, could anyone give me some suggestions?
I'm basing it off of this example, and this one too. What am I doing incorrectly?