I\'m using JQuery lightSlider. It works pretty well (well, actually, I had to jig the code a little bit, but enough of that for now).
What I am trying to achieve is to d
The $("#lightSlider").empty()
or $("#lightSlider").html('')
didn't work for some reason. The lightslider instances continued to pile up with every new form submission. I don't know why. Neither did the ("#lightSlider").lightslider().destroy()
method seem to work, and that could be for some odd reason that I can't pinpoint, maybe something to do with the way I'm manipulating the DOM, I don't know.
What finally worked was to nest the
block within a ...
block. Then, with each new form submission, I deleted the entire #lightSlider block with a $("#carousel-container").html('');
Then I dynamically re-created the entire
with the new, updated content. Here's the working code:...
$("#carousel-container").html('');
var lightsliderstring = "";
for(i=1;i\n";
if( $("#as_feature").val() ){
lightsliderstring += " " + $("#as_feature").val() + " photo " + i + "
\n";
}
lightsliderstring += " \n";
lightsliderstring += "\n";
}
lightsliderstring += "
\n";
$("#carousel-container").html(lightsliderstring);
$('#lightSlider').lightSlider({
auto: true,
gallery: false,
item: 1,
loop: true,
slideMargin: 0,
thumbItem: 0
});