Search code examples
javascriptjqueryselectrss-reader

Using select for change url feed in jquery.rss


i have one problem, i want to use select element for change url of my list using the plugin https://github.com/sdepold/jquery-rss.

This link, is my code with select, but not functional: http://jsfiddle.net/diegomachado/ktz5g892/

jQuery(function($) {
    $("#rss-feeds").rss("http://unsplash.com/rss", {
        limit: 10,
        layoutTemplate: '<ul>{entries}</ul>',
        entryTemplate: '<li>{teaserImageUrl}</li>',
        effect: 'slideFastSynced'
    })
})

Solution

  • <div>
    <select class="feed-source">
        <option value="http://unsplash.com/rss">http://unsplash.com/rss</option>
        <option value="http://antbaena.tumblr.com/rss">http://antbaena.tumblr.com/rss</option>
        <option value="http://devon-jade.tumblr.com/rss">http://devon-jade.tumblr.com/rss</option>
    </select>
    <h1>jquery.rss example</h1>
    <div id="rss-feeds"></div>
    

    jQuery(function($) {
    
        $("#rss-feeds").rss("http://unsplash.com/rss", {
            limit: 10,
            layoutTemplate: '<ul>{entries}</ul>',
            entryTemplate: '<li>{teaserImageUrl}</li>',
            effect: 'slideFastSynced'
        })
    
        $(".feed-source").change(function(){
            $("#rss-feeds").html("");
            $("#rss-feeds").rss($(".feed-source").val(), {
                limit: 10,
                layoutTemplate: '<ul>{entries}</ul>',
                entryTemplate: '<li>{teaserImageUrl}</li>',
                effect: 'slideFastSynced'
            })
        });
    })