php - MagicSuggest dependent multiple dropdowns not working -


i using magicsuggest custom dropdown, have 2 dropdowns category , sub category.. sub categories should populated based on category selection. when select category, , subcategory, work first time, if change category sub categories not change , shows same list. here jquery..

var cat = $('#category').magicsuggest({     maxselection:1,     data: site+'project/getcats/',     valuefield: 'id',     displayfield: 'title',     mode: 'remote',     renderer: function(data){         return '<div>' +                 '<div class="title">' + data.title + '</div>' +             '</div>';     },     resultasstring: true,     selectionrenderer: function(data){         return '<div class="name">' + data.title + '</div>';     } }); $(cat).bind('selectionchange', function(event, combo, selection){     cat_id = cat.getvalue();     src = site+'project/getcats/'+cat_id;     var subcat = $('#sub_category').magicsuggest({         maxselection:1,         data: src,         valuefield: 'id',         displayfield: 'title',         mode: 'remote',         renderer: function(data){             return '<div>' +                     '<div class="title">' + data.title + '</div>' +                 '</div>';         },         resultasstring: true,         selectionrenderer: function(data){             return '<div class="name">' + data.title + '</div>';         }     }); }) 

since no 1 replying take risk..

taken magicsuggest home page http://nicolasbize.com/magicsuggest/doc.html.

i think need use setdata() sets objects listed in combo.

var ms = $('#ms-setdata').magicsuggest({}); ms.setdata(['paris', 'new york', 'gotham']); $(ms).on('selectionchange', function(){     alert(json.stringify(this.getselection()));     this.setdata([         {id:1, name:'blue'},         {id:2, name:'red'}     ]); }); 

if go link posted above, find working example. first choose city eg paris , options changed in colors can select blue.

you can tweak code use setdata on "sub_category"..


Comments

Popular posts from this blog

c - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -