this.initialize has no properties

0 views
Skip to first unread message

sli...@gmail.com

unread,
May 12, 2008, 5:53:33 PM5/12/08
to Ruby on Rails: Spinoffs
Hi, Im new to prototype and am trying to get a grasp on using it.

I created a class with a few methods, but am getting the error
'this.initialize has no properties' I did a search on the site but
didn't uncover anything helpful.

Here is my code:

var methodCall = Class.create({
initialize: function(method,args,loadmessage) {
this.method = method;
this.args = args;
this.loadmessage = loadmessage;
},
call: function(){
DWREngine._execute(_ajaxConfig._cfscriptLocation, null,
this.method, args, this.result);
},
loadMessage: function() {
if (this.loadmessage != '') {
DWRUtil.useLoadingMessage(this.loadmessage);
}
},
result: function(ret) {
$('FCWiz').innerHTML = ret.dump();
}
});

Also, while i am posting, Im using DWR to perform ajax requests
directly on my serverside functions. If you look at the the
methodCall.call() function, you can see the code for doing this. the
last argument is specifies is the function for handling the response.
I would like to make it the methodCall.result() function. I specified
it as this.result, is this correct?

kangax

unread,
May 12, 2008, 8:16:25 PM5/12/08
to Ruby on Rails: Spinoffs
I'm not getting any errors when running this snippet. Which version of
prototype are you using?
It might also be a good idea to bind "this.result" to an instance of
your "methodCall" class:

DWREngine._execute(_ajaxConfig._cfscriptLocation, null, this.method,
args, this.result.bind(this));

- kangax

On May 12, 5:53 pm, "bpick...@forumcomm.com" <slim...@gmail.com>
wrote:

sli...@gmail.com

unread,
May 13, 2008, 10:17:54 AM5/13/08
to Ruby on Rails: Spinoffs
This bit of code gives me the same error:
'Error: this.initialize has no properties
Source File: http://bpickens.in-forum.com/template/js/prototype.js
Line: 48'

var methodCall = Class.create({
initialize: function(method,args,loadmessage) {
this.method = method;
this.args = args;
this.loadmessage = loadmessage;
},
call: function() {
alert(method);
}
});

Im using the newest version downloaded from the site, prototype
1.6.0.2. Do my variable assignments in the initialize() function need
to be bound? And Firebug isn't being very helpful either...

sli...@gmail.com

unread,
May 13, 2008, 10:21:06 AM5/13/08
to Ruby on Rails: Spinoffs
I tried kangax's suggestion, but it didn't change anything.

On May 13, 9:17 am, "bpick...@forumcomm.com" <slim...@gmail.com>
wrote:

sli...@gmail.com

unread,
May 13, 2008, 10:41:52 AM5/13/08
to Ruby on Rails: Spinoffs
I apologize, I realized that I needed to actually create an instance
of methodCall, and then call that. I was trying to call:
methodCall.call('afunction','someargs');

I looked again at the example code in the API docs, and created an
instance like this:
var functionCall = new methodCall('functionCall');

And then called that instance like this:
onclick="functionCall.call('afunction',someargs');"

So, hopefully if any other newbies have the same problem they will be
able to search the group and find this mostly one-sided discussion :)

On May 13, 9:21 am, "bpick...@forumcomm.com" <slim...@gmail.com>
wrote:
Reply all
Reply to author
Forward
0 new messages