javascript - Get custom data attribute of clicked listview item; popup; jqm -
i have dynamically generated listview. each list element assign custom data attribute. when listitem clicked calls popup.
<a href="#popupmenu" data-name='.$myrow[id].' data-rel="popup">view</a>
//mypopup
<ul data-role="listview" data-inset="true" data-theme="b"> <li data-role="divider" data-theme="a">options</li> <li><a id="one" onclick="func1();" href="#">function one</a></li> <li><a id="two" href="#">remove</a></li> <li><a id="three" href="#">cancel</a></li> </ul>
i know correct method retrieve custom data attribute of listview item called popup.
//myjavascipt
var func1 = function() { //display custom data attribute listview click here alert(); };
thanks.
i'm posting jquery based answer because included jquery tag on question, , so, i'm supposing have jquery on project. so:
you use .attr()
method.
if "data" attribute on anchor tag self, should easy (supposing of anchor tags have onclick pointed "func1()":
//display custom data attribute listview click here alert($(this).attr('data-role')); alert($(this).attr('data-name')); alert($(this).attr('data-rel'));
Comments
Post a Comment