Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. JavaScript
  4. jQuery - getting selected item of dynamic listview

jQuery - getting selected item of dynamic listview

Scheduled Pinned Locked Moved JavaScript
csharpjavascripthtmldatabasexml
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Prasoon Chaudhary
    wrote on last edited by
    #1

    I am generating a dynamic collapsible-set with listViews using XML data. It's generated correctly, but I need a click/touch event to display some data before it goes to another page. Here is my code:

    $("#dvAccordion").empty();
    var outdiv = $('

    ');
    $(strXML).find('Category').each(function(){
    var colldiv = $('

    ');
    colldiv.append('

    ' + $(this).find('Category_Name').text() + '

    ');
    var uldiv = $('

    ');
    colldiv.append(uldiv);
    //
    $(this).find('Menu_Item').each(function(){
    var sItemName = $(this).find('item_name').text() ;
    uldiv.append('* ' + sItemName + '
    ');
    });
    //
    //$('#dvAccordion').listview('refresh');
    //
    outdiv.append(colldiv);
    outdiv.appendTo('#dvAccordion');
    });
    //$('#dvAccordion [data-role=collapsible-set]').collapsibleset();
    //$('#dvAccordion').collapsibleset();
    //$('#dvAccordion').collapsibleset('refresh');

    $('#dvAccordion').trigger('create');

    I am adding an eventListener on page load like this:

    $('#dvAccordion ul').children('li').bind('vclick', function(e) {
    alert('Selected Name=' + $(this).attr('data-name'));
    });

    Where am I wrong? If I try to write the same event listner after developing collapsible in static way in html - everything works fine. jsfiddle - http://jsfiddle.net/yesprasoon/MvcHm/

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups