Question

I have a problem. I would like to update a counter (seen by the user as it's 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 works fine, but when I click the button the div is not replaced by sIFR.

Can anybody help?

Was it helpful?

Solution

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.

OTHER TIPS

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!

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"});
}
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top