Comments

Growiel’s picture

Assigned: Unassigned » Growiel

Hi,

Do you have any more information on the error displayed ?

pacoup’s picture

Hello,

I get the same problem when using Ace Editor with the jQuery Update module.

Firefox: TypeError: $(...).live is not a function --- ace_editor.admin.js:192
Chrome: Uncaught TypeError: undefined is not a function --- ace_editor.admin.js?n85i8r:192

This is because of the use of the deprecated .live() function in ace_editor/js/ace_editor.admin.js
http://api.jquery.com/live/
.on() should be used instead.

I tried using .on() and I was able to use Ace Editor with the jQuery Update module.

Growiel’s picture

.live() was removed in jQuery 1.9.

Good catch ! For some weird legacy reasons, I'm still using an older version.

Since you managed to make it work, could you maybe provide a patch that I can test and commit (credits will of course be given where due).

Thanks !

Dave Sandilands’s picture

Thanks Growiel,

I couldn't understand why nothing was happening until I checked the jQuery version I was using via the jQuery Update module. When I went back to 1.7 all was well.

alex.bukach’s picture

Here's a patch.

interdruper’s picture

Assigned: Growiel » Unassigned
Status: Active » Needs work

The patch #5 makes it works under JQuery 1.10, but unfortunately it breaks the editor under JQuery 1.5 and under the defaullt JQuery version provided by Drupal 7.34.

pacoup’s picture

StatusFileSize
new8.16 KB

It's ugly, but it works. Unless you're using something like sweet.js macros, there's no cleaner way to do it that I know of.

interdruper’s picture

#7 works from 1.4 to 1.10, but... not with 1.9. You can test it with the latest 3.x-dev version of JQuery Update, that let you choose 1.9 for the admin theme.

Anyway, as Pacoup pointed out, the approach in #7 is quite ugly... any javascript guru out there that could help on this?

pacoup’s picture

In theory, the check does work for 1.9. Something else in the Ace editor integration must be causing issues. There are already quite a few JS errors with any version of jQuery in this module anyway. Seems to be due for some major refactoring, some of which could solve the ugliness of this fix as well.

Personally though, I think the effort might be better spent on integrating CodeMirror.

interdruper’s picture

Status: Needs work » Reviewed & tested by the community

Ok, finally it seems that changing only a few lines, with a patch based on #5, this issue can be fixed, making Ace runs on all the JQuery versions, from 1.4 (Drupal native) to even the latest (2.1 by now).

I will commit it to dev in a moment.

interdruper’s picture

interdruper’s picture

interdruper’s picture

Status: Reviewed & tested by the community » Fixed

  • interdruper committed 76dd09a on 7.x-1.x
    Revert "Issue #2255597 by interdruper, alex-bukach: Make it work with...
interdruper’s picture

Status: Fixed » Needs work

Unfortunately the tried patch (a common patch for every JQuery version) breaks in some cases the Ace functionalities on modes that are not HTML (like PHP).

Not an easy one this issue... more work (and proposals...) needed. I will close this if a smart common patch appears, valid for every JQuery version from 1.4 to 1.1x.

interdruper’s picture

Ok, here is a new patch that aims to ensure compatibility from JQuery 1.4 to JQuery 1.9 and above.

interdruper’s picture

Status: Needs work » Needs review

  • interdruper committed 82210ac on 7.x-1.x
    Issue #2255597 by interdruper: Make it work with jQuery 1.10 and above
    

  • interdruper committed 3e6cd94 on 7.x-1.x
    Issue #2255597 by interdruper: Make it work with jQuery 1.10 and above
    
interdruper’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

ericras’s picture

This didn't work for me with jQuery 1.4.4. I had to modify the following section

     /**
     * Bind the change event to all text format select lists.
     */
     var toAcify = 'div.text-format-wrapper fieldset.filter-wrapper select.filter-list';

     $(toAcify).change(function(e) {
       var $textFormatWrapper = $(this).parents('div.text-format-wrapper:first');
       acifyWrapper($textFormatWrapper);
     });

to work like the section that was modified in #17:

    /**
    * Bind the change event to all text format select lists.
    */

    // Customize this handler depending on the installed JQuery version,
    // to ensure compatibility from JQuery 1.4 to 1.9+. Issue #2255597
    var iCanUseOn = !!$.fn.on;
    if (iCanUseOn) {
      var func = 'on';
      var selections = 'div.text-format-wrapper fieldset.filter-wrapper select.filter-list';
      var container = 'div#content';
    }
    else {
      var func = 'live';
      var selections = 'div.text-format-wrapper fieldset.filter-wrapper select.filter-list';
      var container = selections;
    }

    $(container)[func]('change', selections, function(e) {
      var $textFormatWrapper = $(this).parents('div.text-format-wrapper:first');
      acifyWrapper($textFormatWrapper);
    });
ericras’s picture

StatusFileSize
new844 bytes

Fixes ongoing jQuery 1.4.4 issue.

interdruper’s picture

Status: Closed (fixed) » Needs review
rajab natshah’s picture

Status: Needs review » Closed (outdated)