PDA

View Full Version : gAjax RSS Feeds Displayer - trigger jQuery function?



kblm
05-24-2012, 05:09 PM
1) Script Title: gAjax RSS Feeds Displayer

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex18/gajaxrssdisplayer.htm

3) Describe problem:

Is there anyway to have the gAjax RSS Feeds Displayer script....make a call to a jQuery function ONCE it's done loading feeds?

I am trying to put this into a jQuery scroller.....the scroller at times is firing before the RSS script is done outputting (I think).

For now, I'm delaying the jQuery scroller with a set time....but I'd like to have the scroller only fire when the RSS feed script is done.

Any clues on how to do that?

-Kevin

kblm
05-24-2012, 05:40 PM
So do you think it's ok to just put my jQuery calls at the end of the:

gfeedfetcher.prototype._displayresult=function(feeds){

function?

Won't this not load the jQuery until all the feeds are written out?

-Kevin

ddadmin
05-24-2012, 10:18 PM
I've just updated the official version of the script (http://www.dynamicdrive.com/dynamicindex18/gajaxrssdisplayer.htm) to incorporate the two features you asked for:

1) Ability to execute your own code when a RSS Displayer has loaded, via the callback function onfeedload()

2) Script now skips a RSS feed entirely if it's invalid, moving on to the next if there are more than one feed defined for a RSS Displayer.

Only the .js file of the script has been modified. To take advantage of 1), just use the syntax:


var newsfeed=new gfeedfetcher("example3", "example3class", "_new")
newsfeed.addFeed("BBC", "http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml") //Specify "label" plus URL to RSS feed
newsfeed.addFeed("MSNBC", "http://www.msnbc.msn.com/id/3032091/device/rss/rss.xml") //Specify "label" plus URL to RSS feed
newsfeed.addFeed("Yahoo News", "http://rss.news.yahoo.com/rss/topstories") //Specify "label" plus URL to RSS feed
newsfeed.displayoptions("datetime snippet") //show the specified additional fields
newsfeed.setentrycontainer("p") //Display each entry as a paragraph
newsfeed.filterfeed(8, "date") //Show 8 entries, sort by date
newsfeed.onfeedload=function(){
alert('hi')
}
newsfeed.init() //Always call this last

kblm
05-24-2012, 10:21 PM
DD Admin

Thank you so much! That is AWESOME!

Going to grab the new code and try it out now.

-Kevin

kblm
05-24-2012, 10:32 PM
I've just updated the official version of the script (http://www.dynamicdrive.com/dynamicindex18/gajaxrssdisplayer.htm) to incorporate the two features you asked for:

1) Ability to execute your own code when a RSS Displayer has loaded, via the callback function onfeedload()

2) Script now skips a RSS feed entirely if it's invalid, moving on to the next if there are more than one feed defined for a RSS Displayer.

Only the .js file of the script has been modified. To take advantage of 1), just use the syntax:


var cssfeed=new gfeedpausescroller("example1", "example1class", 2000, "_new")
cssfeed.addFeed("CSS Drive", "http://www.cssdrive.com/index.php/news/rss_2.0/") //Specify "label" plus URL to RSS feed
cssfeed.displayoptions("date") //show the specified additional fields
cssfeed.setentrycontainer("div") //Wrap each entry with a DIV tag
cssfeed.filterfeed(10, "date") //Show 10 entries, sort by date
cssfeed.entries_per_page(1)
cssfeed.onfeedload=function(){
alert('all done!')
}
cssfeed.init()

Couple of questions....

You have a different var:
var cssfeed=new gfeedpausescroller("example1", "example1class", 2000, "_new")

And a new option:
cssfeed.entries_per_page(1)

I'm guessing these aren't supposed to be in there? When I remove them and set it back to the original gfeedfetcher it works.

-Kevin

ddadmin
05-24-2012, 10:36 PM
Hi Kevin:
Yep, "cssfeed" is just an example, you should replace it with the variable name you used to initialize the script. cssfeed.entries_per_page(1) shouldn't be there, I've removed it.

kblm
05-24-2012, 10:38 PM
Hi Kevin:
Yep, "cssfeed" is just an example, you should replace it with the variable name you used to initialize the script. cssfeed.entries_per_page(1) shouldn't be there, I've removed it.

Yeah I got that part....I was asking about the gfeedpausescroller and the option: .entries_per_page(1)

I need to call gfeedfetcher for it to work.

Are those for a different script?

-Kevin

ddadmin
05-24-2012, 10:42 PM
Ah yes I see why you're confused- I used a variant of the RSS Displayer script, the RSS Scroller, in the sample code I posted. The process is the same, but here is an example initialization code for RSS Displayer itself:


var newsfeed=new gfeedfetcher("example3", "example3class", "_new")
newsfeed.addFeed("BBC", "http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml") //Specify "label" plus URL to RSS feed
newsfeed.addFeed("MSNBC", "http://www.msnbc.msn.com/id/3032091/device/rss/rss.xml") //Specify "label" plus URL to RSS feed
newsfeed.addFeed("Yahoo News", "http://rss.news.yahoo.com/rss/topstories") //Specify "label" plus URL to RSS feed
newsfeed.displayoptions("datetime snippet") //show the specified additional fields
newsfeed.setentrycontainer("p") //Display each entry as a paragraph
newsfeed.filterfeed(8, "date") //Show 8 entries, sort by date
newsfeed.onfeedload=function(){
alert('hi')
}
newsfeed.init() //Always call this last

kblm
05-24-2012, 10:42 PM
Ah yes I see why you're confused- I used a variant of the RSS Displayer script, the RSS Scroller, in the sample code I posted. The process is the same, but here is an example initialization code for RSS Displayer itself:

Thanks so much. Works perfectly!

-Kevin