Worklight and jquery: I want fetch links present i

2019-02-28 16:26发布

问题:

Above attached my image that fetched it remote server its shown as row in the contents page. I have link in the same xml, i want to tag that link to this row and clicking it user should take should be loaded with page.

How can i fetch that?

function displayFeeds(items){
    var ul = $('#itemsList');
    for (var i = 0; i < items.length; i++) {
        var li = $('<li/>').html(items[i].title);

        var l = $('<li/>').html(items[i].link);

        ul.append(li);

    }

This is how I fetch the contents of the xml. I am also fetching the link but do not know how link it to the that row.

Please help.. Regards, Sandy

回答1:

You either need an anchor tag or you need to bind to the li's click event.

var lineItems;

lineItems = $(items).map(function(){
  var item = $(this);
  return '<li><a href="'+item.link+'">'+item.title+'</a></li>'
}).get().join();

ul.append(lineItems);