#4 Declined
Repository
zacharypch zacharypch
Branch
default
Repository
spookylukey spookylukey
Branch
default

Fixes issue #40 - jQuery namespacing issues on django1.4 and django-cms 2.3 update

Author
  1. Zak Patterson avatarZak Patterson
Reviewers
Description

After this, current state of django-cms repo and Django 1.4 work well with semanticeditor.

Comments (3)

  1. Luke Plant repo owner

    I can't see why this would possibly work. All it does is wrap the code in a closure, and passes in exactly the same jQuery instance that was being accessed directly.

    The only difference is that PresentationControls is no longer exported.

  2. Luke Plant repo owner

    Ah, I see - it works because the closure holds on to the jQuery reference as it is defined at the time the code is called, so that even when jQuery is redefined later we've still got the original jQuery reference, which has the necessary plugins attached.

    I'm going to reject this pull request because it is a very noisy way of adding the necessary lines. Thanks for the patch though.

    1. Zak Patterson author

      Hi Luke, It's true, adding the closure only protects this script code from future changes to the jQuery name as a reference. So if someone after this script someone points the jQuery reference to a different instance, we're protected, however if someone does jQuery.fn = undefined, or wipes out some other part of the jQuery object or some jQuery plugin that Semantic would rely on, this will not help.

      So perhaps it's wrong to call this a bug with Semantic, as I contend that there should only ever be one jQuery instance. I just used this method and debugged it this way to work with my site. It's the most frustrating quirk of jQuery usage that I've encountered, since jQuery usage relies heavily on $(document).ready, it seems you can't do much to protect yourself against other users of jQuery as all callers of $(document).ready will end up using the final object as manipulated by different scripts which may follow the one from your project.

      As for PresentationControls, maybe that wymeditor.semantic.js should be tweaked so it's

      var PresentationControls;
      
      (function(jQuery){
        PresentationControls = function(wym,opts){
        
        ...
        }
       ...
        
      })(jQuery);
      

      Anyway I'm happy to be adding SemanticEditor to my latest site, thanks for the project.

      -Zak

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.