My favorites | Sign in
Project Home Wiki
New issue   Search
for
  Advanced search   Search tips   Subscriptions
Issue 159: Unnecessary dependency on Plone's 'jq' jQuery object in types_listing.pt
1 person starred this issue and may be notified of changes. Back to list
Status:  Fixed
Owner:  ----
Closed:  Apr 2011


Sign in to add a comment
 
Reported by danja...@gmail.com, Mar 5, 2011
A minor issue, but worth fixing.

JavaScript code in types_listing.pt includes the line:

jq(this).removeClass('submitting');

It should be:

$(this).removeClass('submitting');

jq is Plone's name for jQuery's usual $ variable. But since type_listing.pt uses a local $ bound to the jQuery object, using jq isn't necessary.

Issue applies to the current trunk, i.e. http://svn.plone.org/svn/plone/plone.app.dexterity/trunk/plone/app/dexterity/browser/types_listing.pt
Line 41.
Mar 6, 2011
Project Member #1 optil...@gmail.com
Actually, the best way to do this is to do:

(function($) {

   ...

})(jQuery);

And then use the $ variable only in that function body.
Mar 6, 2011
Project Member #2 tscho...@gmail.com
Hey,

I think when the initialization is done that way, the code is executed directly when the JS-file is parsed, but the DOM may not be ready at this point.
I had some troubles doing it that way, so I usually do it this way:

jQuery(function($) {
...
});

in this case the function is executed as soon as the DOM is ready (but maybe the DOM-event will get deprecated in some point?).

See also: http://stackoverflow.com/questions/2215904/how-should-i-initialize-jquery

Mar 6, 2011
Project Member #3 optil...@gmail.com
No, I mean, inside that function(), you do:

$(document).ready(function() { ... });

See the jquery docs for details.
Mar 6, 2011
#4 danja...@gmail.com
The way the jQuery is being invoked is fine. It's the standard construct.

(function($){
$(document).ready(function() {

  ...
  jq(this).removeClass('submitting');
  ...

});
})(jQuery);


The only issue is that removeClass call, which references a global jq object when it should reference the local $ object.
Apr 9, 2011
Project Member #5 dgl...@gmail.com
Fixed in http://dev.plone.org/plone/changeset/48635
Status: Fixed
Sign in to add a comment

Powered by Google Project Hosting