Message from JavaScript discussions

July 2017

— Is it will be like this ? TRGWII

— 

$('#datalist').append('<ons-list-item modifier="chevron" tappable ripple class="tombolmenu"><p>'+ el.nama +'</p></ons-list-item>');

$('#datalist').click(

    function bukapaket() {

    document.querySelector('#coreNavigator').pushPage('harga.html');

    document.getElementsByClassName('.judulhalaman').innerHTML = el.nama;

});

?

— Because it doesnt work :/ it will trigger every menu

— Don't use .click on the #datalist

— Use it on the element you create

— But how?

— 

const listItem = $('<ons-list-item modifier="chevron" tappable ripple class="tombolmenu">');

const p = $('<p>');

p.text(el.nama);

listItem.append(p);

listItem.click(...);

$('#datalist').append(listItem);

Message permanent page

— 

$('#datalist').append('<ons-list-item modifier="chevron" tappable ripple class="tombolmenu"><p>'+ el.nama +'</p></ons-list-item>');

i get it, but doesnt know how and where to write .click in this line of code.

Message permanent page

— I see, i will try it

— Wait TRGWII is i need to write my whole bukapaket() function inside that listItem.click(...); ?

— You CAN do that

— Or a function that calls it