2010-02-02 73 views
0

我有一个问题。我想在按下按钮时更新一个计数器(用户看到它显示在某个div中)。所以,出现这种情况时,按下按钮:sIFR和jQuery:动态替换文本

$("#photo-counter span").empty().append((start_index+1)+"-"+(end_index+1)+"/"+files.length); 
sIFR.replace(netto, { selector: "#photo-counter span"}); 

由于在第一次遇到这种自动运行,一切正常,但是当我点击该按钮div不受sIFR取代。

任何人都可以帮忙吗?

+0

也许你也可以提供周围的代码。 – 2010-02-02 19:17:55

回答

0

实际上,你可以这样做:

sIFR.replacements["#photo-counter span"][0].replaceText((start_index+1)+"-"+(end_index+1)+"/"+files.length); 

无需更新HTML,sIFR那样照顾到所有的为你。

0

更多的代码可以用来解决这个问题。

无论如何,这里是一个镜头:

您单击更改以现场点击:

$('#yourElement').live('click', function(){ 
    $("#photo-counter span").empty().append((start_index+1)+"-"+(end_index+1)+"/"+files.length); 
    sIFR.replace(netto,{ 
     selector: "#photo-counter span" 
    }); 
}); 

希望这有助于!

+0

我尝试了下面的代码与现场活动,但它没有工作;(。顺便说一句,你知道是否有像“mouseup”的现场活动? – arold 2010-02-03 10:05:24

+0

以及代码似乎是上面 – arold 2010-02-03 14:29:58

0

这里是全码:

$("#arrow-left").mouseup(function() { 
if(!$("#frame > *").is(":animated") && status != "fullscreen"){ 
$(this).css({"opacity":"1.0"}); 

arrowClick("left"); 
}}; 

function arrowClick(direction) { 
(...) /* i dont think the problem is located somewhere here */ 
refreshCounter(start, end); 
(...) 
} 

function refreshCounter(start_index, end_index) { 
if(files.length > 0) { 
start_i = start_index; 
end_i = end_index; 
if(start_index !=null && end_index != null) { 
$("#photo-counter span").empty().append((start_index+1)+"-"+(end_index+1)+"/"+files.length); 
sIFR.replace(netto, { selector: "#photo-counter span"}); 
} 
}