This issue manifests as a console warning in Google Chrome when certain content types are viewed (as far as I can work out, these are content types created after the installation of Wysiwyg). If it was just a warning that would be fine, but it also prevents devel themer from working properly in these pages, and I expect light box2 as well since both these modules place elements in the footer after the inserted script tag.

The issue does not occur with Bartik theme, but does occur with my custom theme - It seems linked to the module function
wysiwyg_load_editor($profile) calling 'footer')); instead of within the head of the document. If I change the call to drupal_add_js($path . '/wysiwyg.js', array('group' => JS_LIBRARY)); this issue goes away, but then the TinyMCE toolbar is duplicated, so obviously that's not a fix since I expect circumventing the late execution of the Wysiwyg.js functionality causes other problems like the doubled toolbar.

Content types that do not have this issue are loaded in pages without any of the wysiwyg.js script tags - I am not sure if this means these pages have a separate issue (no script tags inserted) or not.

If there is anything I need to try in my theme templates, preprocessing or function overrides to get around this please let me know. On the other hand, if this is better dealt with on the module side, I read that drupal_add_js() should not be used in favor of drupal_add_library() and also wondered if the execution of the Wysiwyg script might not be deferred using a D7 process function override instead of inserting it away from the rest of the head content.

Any advice would be appreciated. In the meantime I am just doing without Devel Themer on these pages while I develop this site and am ignoring the console error - It's not optimal but I have spent several days on this and I need to get back to the actual work by now ;-).

Thanks!

Syntegrator

Comments

TwoD’s picture

Wysiwyg does not do anything different depending on which content type is used, so I don't think it's directly related to that. But maybe the affected content types are themed differently?

The comment above the function call you mention explains why we have to insert the script there, something drupal_add_library() won't allow us to do.

Does jquery.once.js get loaded when the error happens?

Does your theme override drupal/modules/system/html.tpl.php? If so, are you sure the variables in there are printed in the same order? The wysiwyg.js file should be output via the $page_bottom variable, just before the closing body tag.

kha’s picture

More elaborate discussion on the same topic :
http://drupal.org/node/1181562

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 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.
Anyway... If I find an explanation and better solution, I'll post it here.

chadmandoo’s picture

The issue is that is it not loading the jquery.once.js file which is located in the misc/jquery.once.js

Just add this to your html.tpl.php or you can attempt to add it to the info file (not sure if that works). This way you do not actually modify the core module as it may overwrite on the next update.

TwoD’s picture

Status: Active » Closed (duplicate)

#1181562: '$('.wysiwyg', context).once' is undefined was already linked by kha, this is looking more and more like a duplicate.
I'll make sure to put a link in there back here as well, just to make all the info easier to find.

kevzlou7979’s picture

I have also an error in drupal using cloud zoom there was an error on omega-mediaqueries :: Uncaught TypeError: Object #

has no method 'once' Can you give the solution for this..Thanks
TwoD’s picture

@kevzlou7979, There's no way to just know why that happens without more information about exactly when it happens, if scripts have been loaded properly, which editor(s) you're using, etc. Please look through this issue and the one I linked to above to see if any of the suggestions in them fixes it for you.

mikemadison’s picture

#2 seems to fix this for me as well. Thanks for the solution.