tags:

views:

115

answers:

3

Hi,

I ve a problem. I would like to update a counter (seen by the user as its displayed in a certain div) when a button is pressed. So this happens when the button is pressed:

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

As on the first time this runs automatically and everything is fine. But when I click the button the div is not replaced by sIFR.

Can anybody help?

A: 

More code could be usefull for solving this.

Anyway, here is a shot:

Change your click to a live click:

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

Hope this helps!

Fred Bergman
i tried the beneath code with the live event but it didnt work ;(. By the way do you know whether there is a live-event like "mouseup" ?
arold
well the code seems to be above
arold
A: 

here is the full code:

$("#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"});
}
}
arold
A: 

You can actually do this:

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

No need to update the HTML, sIFR takes care of all that for you.

Mark Wubben