NetBeans Forums
| View previous topic :: View next topic |
| Author |
Message |
Michael Joyner Posted via mailing list.
|
Posted: Mon Oct 31, 2011 1:44 pm Post subject: javascript autocompletion support, how do I declare "that" to have the type of "this" for autocompletion? |
|
|
How do I declare "that" to have the type of "this" for autocompletion?
In the following code at "SessionObject.prototype.test", I declare that to be equal to this.
Autocompletion works as well for "this".
Autocompletion does not work for "that". Even if I put "/** @type SessionObject */" before the var declaration for "that". The variable "that" of course being required for proper inner function access to the "this" object.
function SessionObject (){
this.vars={};
this.coverList={};
return this;
}
SessionObject.prototype.bookID=function(){
var bookID=false;
this.getUrlVars();
bookID=parseInt(this.vars['bookID']);
if (typeof bookID == 'undefined') bookID=0;
return bookID;
};
SessionObject.prototype.getUrlVars=function(){
// Read a page's GET URL variables and return them as an associative array.
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
this.vars=vars;
return vars;
};
SessionObject.prototype.test=function(){
var that=this;
this. ;//Completion works for me
that. ;//Completion does NOT work for me, even when /** @type SessionObject */ is used prior to that declaration.
} |
|
| Back to top |
|
 |
aserron
Joined: 07 Jun 2011 Posts: 7 Location: Uruguay
|
Posted: Tue Nov 29, 2011 11:42 pm Post subject: |
|
|
I think Netbeans doesn't have any idea of this as a variable.
this is related to a scope, global scope this = window, in some cases.
I fully agree Netbeans should be aware of this class.
Pd: try this.
| Code: |
if(false){
that = new SessionObject
} |
|
|
| Back to top |
|
 |
khusaini
Joined: 26 Nov 2011 Posts: 10 Location: indonesia
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|