开发者

jQuery Horizontal Ticker with Continuous loop

开发者 https://www.devze.com 2022-12-27 22:05 出处:网络
I am using a jQuery ticker which is pretty cool. It works well with predefined content, butI want to build mytags dynamically by getting the data from a feed via the $.ajax method.

I am using a jQuery ticker which is pretty cool. It works well with predefined content, but I want to build my tags dynamically by getting the data from a feed via the $.ajax method.

http://progadv.uuuq.com/jStockTicker/

The prob开发者_如何学Pythonlem is when I do this the ticker wont work, as it looks like the function might be loading before my page content has loaded. Can anbody think of a way around this?

$(function() {
    $("#ticker").jStockTicker({interval: 45});
});


$(document).ready(function() {
 $("#ticker").jStockTicker({interval: 45});
});


You need to call the jStockTicker function from within the success method with the Ajax call, because like you say, jStockTicker is calculating the dimensions for scrolling before the content has been added to the page.

$.ajax({
    url: 'ajax/test.html',
    success: function(data) {
      //Populate $('#ticker') with data here, e.g...
      $('#ticker').html(data);

      //Now call jStockTicker
      $("#ticker").jStockTicker({interval: 45});
    }
  });

Something like that ought to do it.

Rich


I have never used the jStockTicker; however with another plugin you can change the data dynamically. For example for the jQuery webTicker you can simply replace the content with the list items using javascript and the rotation will continue without halt. I have used this method on a financial website and works like a charm updating the data every few seconds to show the latest exchange rates. The scrolling and dimensions id done automatically per item; once it moves out of screen it is popped back in at the end of of the list. So the list should not break at any point in time


$("#ticker").jStockTicker({interval: 45});

from calling the jStockticker inside success method the scrolling stops and restarts from the begining.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号