【问题标题】:Disabling links in zRSSFeed在 zRSSFeed 中禁用链接
【发布时间】:2011-11-08 19:16:04
【问题描述】:

我正在使用 zRSSFeed 插件在我正在设计的移动网络应用程序中显示几个不同的提要。这些提要不是用户需要单击以获取更多信息的典型提要。大部分信息都包含在标题和 sn-p 中,所以我想禁用标题链接,以免他们在滚动列表时无意中点击它们。

这是加载提要的脚本:

<script type="text/javascript">
    $(document).ready(function() {
        setRSSFeed('#menu');    

        $('#menu').change(function() {
            setRSSFeed(this)
        });

        function setRSSFeed(obj) {
            var feedurl = $('option:selected', obj).val();

            if (feedurl) {
                $('#rss').rssfeed(feedurl, {
                    limit: 20
                });
            }
        }
    });
</script>

【问题讨论】:

  • 生成的 html 是什么样的?
  • 提要显示为基本列表。就像在示例页面上一样 here

标签: jquery rss mobile-website


【解决方案1】:

我让这件事变得比需要的困难得多。

在zRSSFeed js文件中创建行的代码是:

    // Add feed row
    html += '<li class="rssRow '+row+'">' + 
            '<'+ options.titletag +'><a href="'+ entry.link +'" title="View this feed at '+ feeds.title +'" target="'+ options.linktarget +'">'+ entry.title +'</a></'+ options.titletag +'>'

我刚刚删除了 href 标签。

    // Add feed row
    html += '<li class="rssRow '+row+'">' + 
            '<'+ options.titletag +'><a title="View this feed at '+ feeds.title +'" target="'+ options.linktarget +'">'+ entry.title +'</a></'+ options.titletag +'>'

【讨论】:

  • 正确,但这是原始的,为什么不添加新参数来控制链接显示?
【解决方案2】:

为时已晚?我们永远不知道。

在var默认列表中添加subheaderlink: false,subtitletag: 'h3',

我修改后:

if (options.linkredirect) feedLink = encodeURIComponent(feedLink);
/* update from this */
/* create html link or not */
if (options.subheaderlink) {
    var shlink = '<a href="'+ options.linkredirect + feedLink +'" title="View this feed at '+ feeds.title +'">'+ entry.title +'</a>';
} else {
    /* switch the encap tag */
    if (options.subtitletag) {
        var shlink = '<' + options.subtitletag + ' class="shlink">'+ entry.title +'</' + options.subtitletag + '>';
    } else {
        var shlink = '<p class="shlink">'+ entry.title +'</p>';
    }
}
/* modify the call to get the previous build content */     
rowArray[rowIndex]['html'] = '<'+ options.titletag +'>' + shlink + '</'+ options.titletag +'>'
/* to this */

我希望这会有所帮助, 迈克

【讨论】:

    猜你喜欢
    • 2015-06-05
    • 1970-01-01
    • 2017-10-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多