javascript - Dealing with search results and bootstrap modal -
i have php file searches keyword in mysql database table. script builds page lot of products organized brands… when click product shows bootstrap modal more info (calling php file looks particular id of product). modal has 2 buttons , needs able go previous , next product of brand , buttons should disable when reaching first or last product.
this i’ve been doing: while inserting data products in page generate xml file brands , inside each brand, ids of divs corresponding product. have build arrays in javascript handle data. code getting messy i’ve been wondering: what’s best way link products can go , forward in modal?
i ended building this:
<div id='231' data-brand='somebrand' data-brand-index='3'>
then can id jquery:
var x = $("div[data-brand='somebrand'][data-brand-index='2']"); alert(x.attr("id")); //shows 231
Comments
Post a Comment