jquery - Returning ordered json data inside filter.js using JsonQuery -
i'm using filter.js https://github.com/jiren/filter.js - great script.
var fjs = filterjs(products, '#products', { template: '#productfinder-template', search: {ele: '#searchbox'}, callbacks: { beforeaddrecords: function(records){ var jq = jsonquery(records); console.log(jq.order({'artnr': 'asc'}).exec()); }, afterfilter: function(result){ $('#total_products').text(result.length+' records found'); } } });
inside callback "beforeaddrecord" called jsonquery "order" function , result ordered json list, way wanted. problem getting result on screen.
has have experience script?
did testing , found following working. put code on button click testing purposes.
jquery("#xselected").on('click', function(){ var jq = jsonquery(products); products = jq.order({'artnr': 'asc','category':'asc'}).exec(); fjs.removerecords({}); fjs.addrecords(products); fjs.filter; });
removed records filter , added them after using order function jsonquery.
Comments
Post a Comment