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?
on 12.05.2008 23:54
on 13.05.2008 02:17
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>
on 13.05.2008 16:18
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...
on 13.05.2008 16:21
I tried kangax's suggestion, but it didn't change anything. On May 13, 9:17 am, "bpick...@forumcomm.com" <slim...@gmail.com>
on 13.05.2008 16:43
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>