0

I currently have a split button list view with id=bookmarkslist. Each li in the list is a split button list view element with a data('item') tied to each li. I would like to be able to write code that creates a click event only when the secondary button, the split view button, is pushed. I then need to be able to access the data attribute of the given li element (the parent of the a element with class=ui-li-link-alt who has just been clicked. I understand there are many different ways to do this, this is what I have so far:

$('#bookmarkslist SOMETHINGGOESHERE').live('click', function () {
    alert( $(this).data('item')['url'] );
});

Thanks for all the help

1 Answer 1

1

Here's my way to do this:

The HTML snippet:

<ul id="bookmarkslist" data-role="listview">
    <li data-test="whatever1"><a href="#">test #1</a><a href="#">1.2</a></li>
    <li  data-test="whatever2"><a href="#">test #2</a><a href="#">2.2</a></li>
    <li  data-test="whatever3"><a href="#">test #3</a><a href="#">3.2</a></li>    
</ul>

The JQM code:

$("#bookmarkslist a.ui-li-link-alt").live("click", function(e){
      alert($(this).parent("li").jqmData("test")) 
});

This will alert the value of your the data-test attribute on the clicked LI item. Hope this helps!

Have fun...

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.