Groups
Groups
Sign in
Groups
Groups
[CLOSED] Ruby on Rails: Spinoffs
Conversations
About
Send feedback
Help
Management of this in javascript
0 views
Skip to first unread message
Thomas
unread,
May 10, 2008, 1:52:23 PM
5/10/08
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ruby on Rails: Spinoffs
hello
I have a problem with the following code :
var Test = Class.create({
data:"Test",
initialize: function() {
this.t2 = new Test2(this.callt1);
},
callt1: function(){
alert(this.data);
}
});
var Test2 = Class.create({
data: "Test2",
initialize: function(callback) {
this.callback=callback;
},
callt2: function(){
this.callback();
}
});
var t = new Test();
t.t2.callt2();
I get "Test2" but I'm wait for "Test". I think it is not a bug but how
can I do to obtain "Test"
Thomas
kangax
unread,
May 10, 2008, 2:15:07 PM
5/10/08
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ruby on Rails: Spinoffs
That's quite confusing : )
You obtain "Test" like so:
t.t2.callback.call(t)
- kangax
darrin
unread,
May 10, 2008, 3:06:44 PM
5/10/08
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ruby on Rails: Spinoffs
Wow, is this a test?
You can also get "Test" by binding your callback to Test
var Test = Class.create({
data:"Test",
initialize: function() {
this.t2 = new Test2(this.callt1.bind(this));
},
callt1: function(){
alert(this.data);
}
});
Reply all
Reply to author
Forward
0 new messages