Worklight and jquery: I want fetch links present in the xml and want tag them with the row dynamically?

我们两清 提交于 2019-12-02 13:00:56

问题


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);


来源:https://stackoverflow.com/questions/13303422/worklight-and-jquery-i-want-fetch-links-present-in-the-xml-and-want-tag-them-wi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!