|
View:
New views
1 Messages
—
Rating Filter:
Alert me
|
|
|
object function as callback functioni am using cpaint now already for some time - and i am quit happy with it (good job - thanks for it). Now i am working on a new project where i do need to create database objects (persons) on the fly... For this i have decieded to use Javascript Objects - so i build a Javascript Object Person - which takes the PErsons data with the constructor - and then calls the cpaint.call function with that data. As callback function i do have specifid a function inside of my object. I did thought that the function will get called within the object scope. But it does seem to not be so. The callback seems to get called outside the object scope. Is it possible to get the callback function called within the object scope ? Here is my example code: function Person(firstname, lastname, birthdate) { this.firstname = firstname; this.lastname = lastname; this.birthdate = birthdate; this.personid = null; // Will create the Person in the WHIDSYSTEM and set the person id this.cb_createPerson = function(result) { if (!result) { return null; } var person = result.getElementsByTagName('person'); if ((!person) || (person.length!=1)) { return; } person = person[0]; alert(this.firstname); // Will return undefined this.personid = person.getAttribute('personid'); } // Do call the servers create person function cp.set_async(false); cp.call("helpers/cca.php", 'createPerson',this.cb_createPerson,sessionid); // Now we should have created the person so we have the personid // return to async operations cp.set_async(true); } Thanks for hints regards, Wolfgang ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Cpaint-developers mailing list Cpaint-developers@... https://lists.sourceforge.net/lists/listinfo/cpaint-developers |
| Free embeddable forum powered by Nabble | Forum Help |