not 100% sure but something like that happened to me!

mydata, gets re-used! that's why we use the weird case of $.extend()
to make a fresh object instead of just using it....

>>           var mydata = { check_dirty: 1 };


seems to get shared!


>>>>> var mydata = jQuery.extend({},{ check_dirty: 1 })
makes a fresh mydata object
there may be a better way of coding this... but it got me out of a
similar situation!



On 1/26/07, Stephen Woodbridge <[EMAIL PROTECTED]> wrote:
> Ⓙⓐⓚⓔ wrote:
> >           $(".button").bind( "click", function(){       });
> > keeps everything associated with each individual button, throwing in a
> > named function can easily hit some globals!
> >
> > and what is form_dirty?
>
> form_dirty is a boolean global that gets set it my pseudo-form get
> modified, so I can ignore asking the use to save if they move off the page.
>
> > let's see the whole page!
>
> http://imaptools.com/sm/index-002.html - with named function
> http://imaptools.com/sm/index-003.html - with anon function
>
> To test the page, load it can click the "GO" button, it should call
> action_go() and load an image and the select list, this work with the
> anon function.
>
> I want to extract the named function so I can reuse it with the onchange
> event on #files to ask the user to save if the form is dirty. You can
> make the form dirty by clicking on the image.
>
> -Steve
>
> > On 1/25/07, Stephen Woodbridge <[EMAIL PROTECTED]> wrote:
> >> I have a bunch of buttons, and use the following to assign click events.
> >>
> >>              $(".button").each( function() {
> >>                  var data = { check_dirty: 1 };
> >>                  data.action = $(this).text().toLowerCase();
> >>                  if (data.action == 'save') data.check_dirty = 0;
> >>
> >>                  $(this).css("text-align", "center");
> >>                  $(this).bind( "click", data, check_save);
> >>              });
> >>
> >>
> >> The problem is that all the click handlers get the data that is assign
> >> by the last button processed. If I set through firebug, they are all
> >> getting assigned the correct values as the each loop is executing, but
> >> data seems to be global rather then scoped to the anon function!
> >>
> >> What am I missing here?
> >>
> >> -Steve
> >>
> >> _______________________________________________
> >> jQuery mailing list
> >> [email protected]
> >> http://jquery.com/discuss/
> >>
> >
> >
>
>
> _______________________________________________
> jQuery mailing list
> [email protected]
> http://jquery.com/discuss/
>


-- 
Ⓙⓐⓚⓔ - יעקב   ʝǡǩȩ   ᎫᎪᏦᎬ
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to