removing a li by clicking another li using jquery and javascript -
i have problem in removing li clicking li present on page.. , removing li id present in localstorage variable..
here 2 divs present on same page. first li code
<div data-role="page" id="wishlistpage" data-add-back-btn="true"> <div data-role="header" data-position="fixed"> <header id="mainheader" align="center"> <a href="#"><img src="images/logoname.png" /> </a> </header> </div> <div data-role="content" data-theme="a" id="wishproducts"> <ul id="wishlist" data-role="listview"></ul> </div> </div>
li sets attributes values coming databse rs.rows.item(i).id
$("#wishlist").append('<li id="'+rs.rows.item(i).id+'"><a href="index.html#removeproductdialogpage" data-role="button" data-rel="dialog" data-transition="slide" data-ajax="false" onclick=savevaluesinlocalstorage("'+rs.rows.item(i).id+'","'+rs.rows.item(i).productname+'","'+rs.rows.item(i).imagename+'","'+rs.rows.item(i).vendorimagename+'","'+rs.rows.item(i).fixedprice+'","'+rs.rows.item(i).finalprice+'","'+rs.rows.item(i).authorname+'","'+rs.rows.item(i).sharingurl+'");>' + '<img src='+rs.rows.item(i).imagename+' id="itemimage"/>'+ '<span id="dataname"><h4>'+pname+'</h4></span>' + '<p><span id="dataauthorname">'+aname+'</span></p>' + '<p><span id="itemrsprice">rs. </span><span id="itemstrikeprice"><strike>'+rs.rows.item(i).fixedprice+'</strike></span> <span id="itemprice">'+rs.rows.item(i).finalprice+'</p></span>'+'<img src='+rs.rows.item(i).vendorimagename+' id="itemsite"/></a></li>'); } $("#wishlist").listview("refresh");
here wishlist id of ul.. , store in localstorage code is..
function savevaluesinlocalstorage(producturl, productname , productimagename , vendorimage , fixedprice, finalprice, authorname,sharingurl){ localstorage.sharingurl = sharingurl; localstorage.producturl = producturl; localstorage.productname = productname; localstorage.imagename = productimagename; localstorage.vendorimage = vendorimage; localstorage.fixedprice = fixedprice; localstorage.finalprice = finalprice; localstorage.authorname = authorname; }
now want delete li have id localstorage.producturl
and dialog page :
<div data-role="content" data-theme="a"> <ul name="options" id="options" data-role="listview"> <li> <a href="#" data-theme="a" data-ajax="false" onclick=" removeinfodatabase()"> <p><span id="itemname"><h4>remove wish list</h4></span></p> </a> </li> <li> <a href="javascript:void(0);" data-theme="a" data-ajax="false" onclick="openweblink()"> <p><span id="itemname"><h4>go store</h4></span></p> </a> </li> </ul> </div>
the following code shows phonegap sqlite code. , removeinfodatabase() function is..
function removeinfodatabase (){ db.transaction(removeelement, removeerror, removesuccess); } function removeerror(err){ console.log("error processing sql: "+err.code); alert("couldn't remove wish list"); } function removesuccess(){ var elem =document.getelementbyid(localstorage.producturl); elem.parentnode.removechild(elem); // $("#"+localstorage.producturl).remove(); // var mm = $("#"+localstorage.producturl).html(); // alert(""+mm); $("#wishlist").listview("refresh"); alert("item removed successfully"); history.back(); } function removeelement(tx){ tx.executesql('create table if not exists itemdetail (id unique, productname , imagename, vendorimagename , fixedprice , finalprice , authorname , sharingurl)'); tx.executesql('delete itemdetail id="'+localstorage.producturl+'"'); }
now how cal remove wishlist li after clicking remove wishlist li please me.. please in advance..
assuming 2 pages on same site (such share same localstorage
object), easiest option use settimeout()
on page going have element removed, poll local storage presence of id.
function pollstorage() { var id = localstorage.id; if (typeof id !== 'undefined') { delete localstorage.id; $(id).remove(); } settimeout(pollstorage, 100); } pollstorage();
Comments
Post a Comment