How to assign function to onclick in List View Node?

Get help with using Metro 4 components
Post Reply
tylorngo
Posts: 1
Joined: Fri Aug 09, 2019 6:53 pm
Status: Offline

How to assign function to onclick in List View Node?

Post by tylorngo » Fri Aug 09, 2019 7:00 pm

My code is below. How can I assign a method to newly created node? The code below does not work.

<ul data-role="listview" id="Cat" data-view="content" data-select-node="true">
@{
foreach (var cat in Model.listCat)
{
<li data-icon="<span class='mif-folder fg-orange'>"
data-caption="@cat.cat_name"
data-content="<div class='mt-2' data-small='true'>"
onclick="displaySubCat('@cat.cat_name');"></li>

}
}
</ul>

function addNode(id){
var lv = $("#Cat");
lv.data('listview').add(null, {
caption: newCatVal,
icon: "<span class='mif-folder fg-orange'>",
content: " <div class= 'mt-2' data-small='true'>",
onclick: "displaySubCat('" + newCatVal + "');"

});

};

Post Reply