PDA

View Full Version : double-firing lightwindow



sapp5
06-25-2009, 04:19 PM
I hope it's ok to post in here about lightwindow, since lightwindow's own forums have been down for a while... I've implemented it on a site and everything's running fine, except for one thing: When a user double-clicks on links with the "page" parameter (they also have width and height params), the script seems to fire twice resulting in a double-sized lightwindow with two stacked versions of identical content. :eek: This can be seen on this page (http://www.splurgebakery.com/packaging.php).

This problem is not occurring on non-"page" lightwindows. On other pages (http://www.splurgebakery.com/holiday.php) I have image-only lightwindows and gallery lightwindows. No problems there.

I've looked into using JS to disable the link briefly after the first click, similar to form submission buttons, but I haven't found a workable solution. I also tried looking through lightwindow.js for something I could alter, but short of a glaring error in the code I'm not knowledgeable enough to find anything.

Any ideas anyone has for tackling this issue would be greatly appreciated!

blizzo
03-12-2010, 03:09 AM
I realize this is way too late, but I stumbled across this posting while trying to find a solution to my problem, and ended up fixing it myself. Here was my solution, all changes are in lightwindow.js.

near the top, i added a variable called currentlyFetching and default it to false



windowActive : false,
currentlyFetching : false,
dataEffects : [],


then in the _loadWindow function, in the page: block about half way down the file, i wrapped the ajax call in an if block, and reset the variable in the oncomplete:



case 'page' :
if (this.currentlyFetching == false) {
this.currentlyFetching = true
var newAJAX = new Ajax.Request(
this.contentToFetch, {
method: 'get',
parameters: '',
onComplete: function(response) {
$('lightwindow_contents').innerHTML += response.responseText;
this.resizeTo.height = $('lightwindow_contents').scrollHeight+(this.options.contentOffset.height);
this.resizeTo.width = $('lightwindow_contents').scrollWidth+(this.options.contentOffset.width);
this._processWindow();
this._processPostloadAction();
this.currentlyFetching = false;
}.bind(this)
}
);
}

break;



Now, any subsequent ajax requests will drop until the first one is completed.