Hi, I''m having an issue with class variables, after upgrading to 1.6 in the initialize function i have this.currentItem = ''''; The class method switchTo is called by a mouseover event. this.currentItem is then changed to for example ''3SE0723W-25-30'' Then class method resetImage is called by a mouseout event. this.currentItem has not been touch during this time... yet in the resetImage method the value of this.currentItem is false... ? Thanks Rob --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Just 1 more thing...
It shouldn''t matter if the class method is being called from within a
method within another class.
I have declared the class instances globally.
this is a simplified version of my class:
------
var imageSwapper = Class.create({
initialize: function()
{
this.currentItemCode = '''';
},
switchTo: function(variant,toselect)
{
this.currentItemCode = ''3SE0723W-25-30'';
},
resetImage: function()
{
if(currentItemCode)
{
alert(''image code set'');
}
else
{
alert(''no item code'');
}
}
});
var image_swapper;
function initImageSwapper() { image_swapper = new imageSwapper(); }
Event.observe(window, ''load'', initImageSwapper);
------
On Dec 27, 12:12 pm, Rob <rald...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hi,
> I''m having an issue with class variables, after upgrading to 1.6
>
> in the initialize function i have
> this.currentItem = '''';
>
> The class method switchTo is called by a mouseover event.
> this.currentItem is then changed to for example
''3SE0723W-25-30''
>
> Then class method resetImage is called by a mouseout event.
> this.currentItem has not been touch during this time... yet in the
> resetImage method the value of this.currentItem is false... ?
>
> Thanks
> Rob
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
Just 1 more thing...
It shouldn''t matter if the class method is being called from within a
method within another class.
I have declared the class instances globally.
this is a simplified version of my class:
------
var imageSwapper = Class.create({
initialize: function()
{
this.currentItemCode = '''';
},
switchTo: function(variant,toselect)
{
this.currentItemCode = ''3SE0723W-25-30'';
},
resetImage: function()
{
if(this.currentItemCode)
{
alert(''image code set'');
}
else
{
alert(''no item code'');
}
}
});
var image_swapper;
function initImageSwapper() { image_swapper = new imageSwapper(); }
Event.observe(window, ''load'', initImageSwapper);
On Dec 27, 12:12 pm, Rob <rald...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hi,
> I''m having an issue with class variables, after upgrading to 1.6
>
> in the initialize function i have
> this.currentItem = '''';
>
> The class method switchTo is called by a mouseover event.
> this.currentItem is then changed to for example
''3SE0723W-25-30''
>
> Then class method resetImage is called by a mouseout event.
> this.currentItem has not been touch during this time... yet in the
> resetImage method the value of this.currentItem is false... ?
>
> Thanks
> Rob
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
I can''t think of anything different in 1.6 (in this context) except
that event callbacks are now bounded to their elements. Even so, this
hardly seems to be a problem, since I''m sure you are binding your
callbacks the proper way.
$(''foo'').observe(''click'', function() {
this.addClassName(''active''); // <= "this" was
not guaranteed to
refer to $(''foo'') in <1.6
})
$(''foo'').observe(''click'',
this.resetImage.bind(this)); // <= should be
fine when used in instance method
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---