hi,
How do I loop a list component items using javascript or jquery?
Thanks
hi,
How do I loop a list component items using javascript or jquery?
Thanks
Hello!
Please try the following
prevar listitems = $("[name=YOUR_LIST_GOES_HERE_NAME]");/pre
That gives me a reference to the list component. And then to loop I tried this
code
var listitems = $("[name=YOUR_LIST_GOES_HERE_NAME]");
listitems.each(function() {
console.log($(this).text());
});
/code
I know I am missing something small here
OK thanks I got it
Hi guys
This seems good, but how would you write the JS to loop through each item and ex. get each item "name" property from the individual list items?
Or let's say I wanted to change the "visible" property on all list items, which has class=allowed ?
Thanks!
Hello Christian!
Sorry, but writing custom JS is outside the scope of support.
We may try to help if you clarify what have you tried and what exactly doesn't work?
No worries. I figured it out with help from another answer from this forum.
For future reference (for other developers), here's how I made it work for me:
This JS runs as Success Event from a DB service:
Code: Select all
if (data === null || data.length === 0)
{
alert("No data received");
}
else {
$.each(this.response.body, function(index, val) {
var listitems = $("[name=productListItem]");
$.each(listitems, function(index, value) {
if ($(this).find("[name=productID]").html() == val.product_id) {
$(this).show();
}
});
});
}
Thanks for posting that!