This did the trick, thanks James.

On Mar 4, 6:23 pm, James <james.gp....@gmail.com> wrote:
> Another option is to use the live() function.:
>
> $('a[rel="lesson"]').live('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;
>
> });
>
> Just call this once when your page loads (don't put this function in a
> variable) and everything should be set for now and the future. (Thus,
> you don't have to call it again in your AJAX complete callback
> function)
>
> On Mar 4, 8:21 am, James <james.gp....@gmail.com> wrote:
>
> > Everytime you're calling that function, you're adding an addition
> > click event to it. One option is to unbind any existing onclick events
> > and then re-bind it.:
>
> > $('a[rel="lesson"]').unbind('click').click(...)
>
> > On Mar 4, 5:42 am, inertiahz <p.thripple...@googlemail.com> wrote:
>
> > > 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