I am working on jQuery Mobile.
I have a view in which I am displaying the collabsible list which is being loaded dynamically. Hence my jQuery file gets the JSON data, runs the loop around $('mylist').append(..data for each row..)
.
Now in every collapsible item, I am adding a button which has to run a JavaScript function alongwith the parameters. This is where I am stucked. Somehow the event is not fired on click. Is it because of the fact that no event is generated or the the parameters I am passing in variables are the main problem.
$('#main')
.bind("pageshow", function (event) {
var cusid = getUrlVars()["cusid"];
var locid = getUrlVars()["locid"];
$.getJSON("localhost/mserv/Offers.php";, function(data) {
$.each(data, function(index, offer){
$('#cat_list').append("<div align='center' data-role='collapsible'><h3>offer.name</h3><p>offer.price</p><input type= 'button' onclick='addItem("+offer.id+",'"+offer.name+"',"+offer.price+")' value='Add To Cart'></div>");
});
$('#cat_list').collapsibleset('refresh');
});