Hi there,

Just getting started with javascript and jquery on a site im
developing, however i cant figure a way around a function executing
repeatedly.

I have some code to open all links with rel='lesson' in a new window
$('a[rel="lesson"]').click( function() {
window.open(this.href, "_blank", "channelmode=0, directories=0,
fullscreen=0, height=820, left=0, location=0, menubar=0, resizeable=1,
scrollbars=0, status=1, titlebar=1, toolbar=0, top=0, width=1044");
return false;
});

Now this works fine, however i also have seperate places on the page
that are pulling through other pages through the ajax call, however
the links dont activate the above bit of code.

I have tried putting the above code in a variable like:
var openNew = function() {
$('a[rel="lesson"]').click( function() {
window.open(this.href, "_blank", "channelmode=0, directories=0,
fullscreen=0, height=820, left=0, location=0, menubar=0, resizeable=1,
scrollbars=0, status=1, titlebar=1, toolbar=0, top=0, width=1044");
return false;
});
};

Then calling the variable when the page loads with:
openNew();

Then also calling it again in the complete option in the .ajax
request.  This would then work for the links that have been pulled
through, however all links that were already on the page originally
would then open twice, or however many times the ajax request has been
called.

Can anyone point me in the right direction as to how to fix this?

Thanks
Paul

Reply via email to