Hi, when i tried to install the TinyMCE editor, nothing is showing up for me.
When i check on js error's, i get the following:

Result of expression '$('.wysiwyg', context).once' [undefined] is not a function.

Is this an error within my wysiwyg module?


Members fund testing for the Drupal project. Drupal Association Learn more


TwoD’s picture

Status: Active » Postponed (maintainer needs more info)

Sounds like you might be missing a jquery file defining the "once" function. Check with Firebug for Firefox (or a similiar development tool) where you can see the requested files for each page - clear the browser cache, then check Firebug's Net tab when reloading the page. If any files are not listed with a HTTP status code of "200 OK", you'll need to check that the files exist and have read permissions so the server can hand them out.

TwoD’s picture

Title: TinyMCE error » '$('.wysiwyg', context).once' is undefined
Component: Editor - TinyMCE » Code
Assigned: tomroelandt » Unassigned
sun’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

Sorry, without further information this issue can only be closed as not reproducible.

Feel free to re-open this issue if you want to provide further information. Thanks.

WilliamB’s picture

Same issue with Ckeditor

$(".wysiwyg", context).once is not a function in firebug.

TwoD’s picture

@WilliamB, can you check what I said in #1?

WilliamB’s picture

Found out it was bc i made a tweek to add jquery to the javascript, as it seems it doesn't load when a form comes back with an error (like title forgotten).

But that messed it up for the custom jquery used by drupal which declare .once.

So it isn't related to your module sorry.

Still looking for a fix to that behaviour of drupal form though.

TwoD’s picture

Drupal doesn't use a custom jQuery build. It runs one of the official releases, which one depends on which Drupal version you're using. If you need a later version of jQuery, I suggest trying it via the jQuery update module. It is compatible with Wysiwyg module.

asghar’s picture

Hi guys

I was facing this issue but i have solved it. Might be it help you.

In my theme directory there was js/default.js file which was attached through template.php i think it is extra js library file which was conflicting with drupal js . In short check your system might be you added extra js library.


Dr. Bytes’s picture


The theme I was working with did not have a "default.js" file, but, it was trying to load it's own version of jQuery, and thanks to your post, my issue (which was the same as OP) is now solved.

Thanks a bunch, and a note to others: verify that your theme or an alternate module is not trying to override Drupal's built-in/loading .js libraries.

asghar’s picture

Wow great man ...

kha’s picture

I had the same problem, only the message was $('wysiwyg' doesn't have once method.
CKEditor appears in bartik theme, but not in my custom theme.
After browsing the net, I have checked everything and found a replacement for the once function.
I changed the following line (46) in wysiwyg.js ;
$('.wysiwyg', context).once(function() {
becomes :
$('.wysiwyg:not(.processed)', context).addClass('processed').each(function() {

And boom, the CKEditor appears. Now, Why is wysiswyg the only object wich is refused the once method ? I don't know.

varunity’s picture

150 bytes

Thanks Kha, confirmed working with 7.x-2.1.

Patch attached.

lumbric’s picture

I can confirm, #11 solved the problem.

Drupal: 7.14
Wysiwyg Module: 7.x-2.1
Browser: Firefox 15.0.1

granticusiv’s picture

I can confirm the patch has worked for me too. I had included this line in my theme's info file.

scripts[] = js/jquery-1.7.2.min.js

I'd included it in my .info file because I found if I just included jquery libraries/scripts in my html or page templates, some pages of the site would not include the libraries, and my custom jquery functions wouldn't work. If I was logged in as administrator, the jquery functions would always work.

Anyway, perhaps in the future I'll try including a sliding banner script in the info file, instead of bringing in an entire jquery library.

Drupal: 7.14
Wysiwyg Module: 7.x-2.1

TwoD’s picture

Re #12, Drupal core includes misc/jquery.once.js which defines the jQuery Once Plugin from http://plugins.jquery.com/project/once.
If that is undefined, check that your browser was able to load it, and if it was requested at all, using a developer tool like Firebug for Firefox or your browser's own tools.

@granticusiv, manually adding a script tag including jQuery in your templates will probably not override the version of jQuery loaded by Drupal core, which means you can end up loading it twice, with some extensions only being used by one instance or the other.
I'm also pretty sure that including it from an .info file like that will have the same effect, as Drupal can only override a previous version of a script if it has the exact same name. Drupal core loads jQuery 1.4.4 from misc/jquery.js, which means you should now have both versions 1.4.4 and 1.7.2 included on all pages.
Have you checked that there is only one version of the jQuery files being added to the document <head>?

chadmandoo’s picture

Post #15 was correct. Instead of patching you could simply add the js file to your theme files. This way if wysiwyg is ever updated, it will not override the changes.

TwoD’s picture

Marked #1671210: Object #<Object> has no method 'once' when called from Drupal.behaviors.attachWysiwyg (line 47, wysiwyg.js) a duplicate. In there this problem happens with a custom theme, but not with Bartik, indicating that the theme may be responsible for jquery.once.js not being included.

roynilanjan’s picture

437 bytes

#11 is correct one so making a patch on the basis of it! #12 patch format is incorrect won't run!

TwoD’s picture

@roynilanjan, that's the wrong way to fix the issue. Your patch takes care of a symptom, not the cause. The jQuery .once() method is provided by a file in Drupal Core, misc/jquery.once.js. If that file is missing or can't be accessed by the browser you will have problems with a lot more modules than just Wysiwyg, including several Drupal Core modules which use the .once() method.
Find out why the that file isn't getting properly loaded/parsed instead.

roynilanjan’s picture

@Twod - solution has already been given #11 & #12 .. but in #12 the patch format was incorrect that I corrected just!
Yes one thing is that my case as I used one external integration by a js widget(which also load Jquery version) this might be the cause as two different versions of jquery are loaded(along with drupal jquery version)
Let me check again to revert back the code in original state & observe the result whether my assumption is correct or incorrect

oranges13’s picture

I wanted to say thank you for the detailed responses in this thread. I discovered that our theme was manually including jquery which did not include the once method. Once I removed that it works as intended. Thank you so much.

Stephen Ollman’s picture

Patch @ #18 worked perfectly with latest D7 version (7.x-2.2) of WYSIWYG and CKEditor library 4.2

JS error now gone and toolbar displaying again.

laboratory.mike’s picture

Status: Closed (cannot reproduce) » Closed (works as designed)

This method is also not the best, like #11, but what I did was copy Drupal's jquery.once.js to my theme file, next to the jquery file I was planning to use. Within it theme's .info file, I called both jquery-1.10-2.min.js and jquery.once.js, then the script I wrote, and now I have my jQuery script working well on the front end, and TinyMCE is also working with WYSIWYG's .once implementation.

The .once function was meant to shorten the code from #11/#18, and if it's used elsewhere in Drupal, it is probably not best to do it that way. I can't say my solution is the best either, but it does make sure that jquery.once.js is loaded, and IMO this is not a WYSIWYG issue, but an issue with correctly injecting jQuery onto a page, and it just happens to be visible when improperly injecting jQuery while using WYSIWYG at the same time.

mj2013’s picture

#8 solved my issue, thank you!

I was experimenting with a mobile menu and loaded an additional jquery library. Once unlinked the library from my theme's .info file, there were no more errors and wysiwyg worked again.

huslabs’s picture

Issue summary: View changes

Patch @ #18 worked perfectly .. Thank you very much

khoomy’s picture

543 bytes

#18 does not work with 7.x-2.2 version. Updated patch is attached herewith


oranges13’s picture

So, this issue is closed so further patches won't go to any use - this is not a problem with the WYSIWYG module, if you're having this problem, your theme is not correctly including jQuery.

TwoD’s picture

@khoomy, @oranges13 is correct, see comments #1, #15 and #17.
Your patch would seriously alter the behavior of Wysiwyg if Drupal.behaviors.attachWysiwyg.attacj() got called multiple times for the same element (which can happen), and would confuse the module as to whether it has already processed a field.