sIFR et jQuery: texte dynamiquement remplaçant
Question
J'ai un problème. Je voudrais mettre à jour un compteur (vu par l'utilisateur comme il est affiché dans une certaine div) lorsqu'une touche est enfoncée. Donc, cela se produit lorsque le bouton est pressé:
$("#photo-counter span").empty().append((start_index+1)+"-"+(end_index+1)+" / "+files.length);
sIFR.replace(netto, { selector: "#photo-counter span"});
Comme sur la première fois exécute automatiquement et tout fonctionne très bien, mais quand je clique sur le bouton, le div
n'est pas remplacé par sIFR
.
Quelqu'un peut-il aider?
La solution
Vous pouvez réellement faire ceci:
sIFR.replacements["#photo-counter span"][0].replaceText((start_index+1)+"-"+(end_index+1)+" / "+files.length);
Pas besoin de mettre à jour le code HTML, sIFR prend soin de tout cela pour vous.
Autres conseils
code plus pourrait être utile pour résoudre cela.
Quoi qu'il en soit, voici une photo:
Modifiez votre clic à un clic en direct:
$('#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!
Voici le code complet:
$("#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"});
}
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow