Page 1 of 1

Methods in jQuery JavaScript Profile always return jQuery

Posted: Tue May 27, 2008 11:20 am
by sergey_che
Spket completely ignores JSDoc @return properties in files added in jQuery JavaScript Profile, causing all methods to return jQuery objects, which is incorrect behavior, because jQuery has number of methods that returns different result types (string, boolean, array etc.). For example, offset() method return Object, get() returns Element and so on. Here is a test case:

1. Create simple file and add it to default JavaScript Profile:

Code: Select all

/**
 * @return {Object}
 */
jQuery.prototype.offset = function(){ return {top: 0, left: 0};};
2. Write this in editor:

Code: Select all

$('div').offset(). //code assist shows that offset() return jQuery
Or maybe I do something wrong?

Posted: Wed May 28, 2008 2:42 am
by eric_suen
Currently the jQuery support is not very good, and if you and file to the profile, it will ignore the function body, so the code "return {top: 0, left: 0}" will be ignored by profile...

If you add the code to the file you edited, the code assist will work(please remove the JSDoc, @return {Object} will cause code assist ignore the function body)

Code: Select all

jQuery.prototype.offset = function(){ return {top: 0, left: 0};};

Posted: Wed May 28, 2008 8:18 am
by sergey_che
Maybe there is a way to add file into JavaScript profile without specifying library type? I made complete documentation js-file for jQuery (I can share it, but I can't post links here until I get 10 posts) and I would like to use it in js editor by default.

Posted: Wed May 28, 2008 9:08 am
by eric_suen
Currently the solution is using include tags, take a look at this thread: viewtopic.php?t=365

I will try to fix this issue in next version.

Posted: Wed Aug 05, 2009 11:29 am
by tiffanly
How do you get JavaScript to be turned on? If you already have Javascript downloaded and its turned off then how do you get it turned on again?