I have a page where I have a views slideshow with cs adaptive images in it. The page also has a form which is submitted via ajax. When the form is submitted, the adaptive image javascript behavior fires again and images are inserted again.
to fix this, in cs_adaptive_image.js replace
// Insert adapted images.
$('noscript.adaptive-image').addClass('adaptive-image-processed').each(function(index) {
var img = getAdaptedImage(this);
$(this).after(img);
});with
// Insert adapted images.
$('noscript.adaptive-image:not(.adaptive-image-processed)').addClass('adaptive-image-processed').each(function(index) {
var img = getAdaptedImage(this);
$(this).after(img);
});| Comment | File | Size | Author |
|---|---|---|---|
| #11 | 1667874_cs_adaptive_image_once-11.patch | 944 bytes | dalin |
| #8 | 0001-cs_adaptive_image-use-behaviour-Issue-1667874-8.patc_.patch | 943 bytes | sandervd |
| #3 | cs_adaptive_image-twice-1667874-3.patch | 922 bytes | david lesieur |
| #2 | ajax_duplicate-1667874-2.patch | 605 bytes | albert volkman |
Comments
Comment #1
drew reece commentedI'm seeing this too, but my use case is a little different.
I have a slideshow-view page that is loaded into a colorbox overlay via ajax on page load, I see multiple copies of the adaptive images in the colorbox.
If I use 2pha's code I only see one image and it works correctly.
I think the .once() function is intended for this use case e.g.
edit: This looks like a duplicate of http://drupal.org/node/1585342
Comment #2
albert volkman commentedConfirmed that the fix from #1 resolved the issue. Here's a patch.
Comment #3
david lesieur commentedI like the idea of using the once() method.
How about this patch? Does it work for you?
Comment #4
drew reece commentedThe patch in #3 works for me.
Comment #5
albert volkman commented#3 works for me, and the code is cleaner.
Comment #6
david lesieur commentedCommitted, and forgot to credit my own contribution. ;-)
Comment #8
sandervd commentedThe correct way would be to use the context of the behaviour
Comment #9
SGhosh commentedPatch in #3 worked for me.
Comment #10
dalinThe more correct way would be to combine both #3 and #8 - to use context _and_ .once().
Comment #11
dalinNew patch based on #10
Comment #12
hedel commented#11 worked for me (problem was in a Views slideshow with Lightbox)
Comment #13
david lesieur commentedCommitted #11, but I have replaced
once('adaptive-image').each(function() {withonce('adaptive-image', function() {since the once() function can perform the iteration.Comment #14
david lesieur commentedComment #15.0
(not verified) commentedspelling mistakes