hi.. i dynamically load html elements.. and used livequery() plugin to handle click events.. but only the first element could be clicked.
here's my initial DOM:
<div id="styleList">
<h4 class="subPaneTitle blurred">List of themes</h4>
<ul>
<li class="listHeader"><span class="themeID">Theme ID</span><span class="themeName">Theme Name</span>
<span class="themeAction">Action</span>
</li>
</ul>
<p class="createNewStyle clearfix"><a id="createNewStyle" class="btnStyle1 blurred ui-corner-all">Create new theme</a></p>
</div>
here's my code to load dynamically the elements from xml:
$.get("http://localhost/ShopNGo_Blitz_revised_w_YAML/site_styles_list.xml",loadAllThemes);
function loadAllThemes(data){
$(data).find("style").each(function(){
var thisStyle = $(this);
var styleID = thisStyle.attr('id');
var styleName = thisStyle.attr('name');
var styleStatus = "";
if(thisStyle.attr('status') == "used"){
styleStatus = '<span class="statusIndicator">Current theme</span>';
}
$("#styleList ul").append('<li><span class="themeID">'+ styleID + '</span><span class="themeName">' + styleName + '</span><span class="themeAction"><a id="themePreview">Preview</a></span><span class="themeAction"><a id="themeEdit">Edit</a></span><span class="themeAction"><a id="themeDelete">Delete</a></span><span class="themeAction"><a id="themeUse">Use</a></span>' + styleStatus + '</li>');
});
}
here's my code for the 'Edit' click event:
$("div#styleList").find("ul").find("li").find("a#themeEdit").livequery("click",function(){ //this gets only the first element.
var themeName = $(this).parent().prev().prev(".themeName").text();
$("#siteStyleContent").tabs("select","#styleEditTabs");
$("div#styleEditTabs").children("#themeName").text(themeName);
});