jquery - Cannot get isotope to sort by number -
i'm trying isotope sort number in p.number (one p.number inside each div.box) , of div.box inside #content (my jquery below build markup) right of div.box divs stacking on top of each other --- want when when click on button, div.box sort number found in p.number tag
this error in web console: typeerror: '.number parseint' not function (evaluating 'ea')
<body> <div class="wrapper"> <div id="sorts"> <button>sort number</button> </div> <div id="content"> </div> </div> <script> var mydata = [ { "number" : "15", "promoimage_title" : "title here item 1" }, { "number" : "28", "promoimage_title" : "title here item 2" }, { "number" : "58", "promoimage_title" : "title here item 3" }, { "number" : "37", "promoimage_title" : "title here item 4" }, { "number" : "4", "promoimage_title" : "title here item 5" }, { "number" : "8", "promoimage_title" : "title here item 6" }, { "number" : "23", "promoimage_title" : "title here item 7" }, { "number" : "88", "promoimage_title" : "title here item 8" }, { "number" : "27", "promoimage_title" : "title here item 9" }, { "number" : "67", "promoimage_title" : "title here item 10" } ]; $.each(mydata, function(index, value) { $('#content').append("<div class='box'><p class='number'>"+value.number+"</p><p class='box-title'>"+value.promoimage_title+"</p></div>"); }); var $container = $('#content'); $container.isotope({ itemselector: '.box', layoutmode: 'masonry', getsortdata: { number: '.number parseint' } }); $('#sorts').on( 'click', 'button', function() { $container.isotope({ sortby: 'number' }); }); </script> </body>
Comments
Post a Comment