By nhocmuonlanhoc on
i try to use drupal_add_js() function to add some java script & jquery library for my module
all is ok but when i logged in admin area it show
$("#toolbar", context).once is not a function
$('#toolbar', context).once('toolbar', Drupal.toolbar.init);
who know about this error ? Please show me how to fix it ?
Many thanks
Best regards
Hle
Comments
.once() is not a jQuery
.once() is not a jQuery function, so it doesn't work.
Contact me to contract me for D7 -> D10/11 migrations.
Thanks Jay Matwichuk, but i
Thanks Jay Matwichuk,
but i i think it is a function of drupal core
$('#toolbar', context).once('toolbar', Drupal.toolbar.init);
it's not my function
Where does the jQuery code
Where does the jQuery code from? I would expect if that is Drupal related there would be a Drupal module that handles adding the javascript.
This is happening for me
This is happening for me too. This is the guilty code from toolbar.js in the Toolbar module. 7.x-rc4.
Same issue here
Subscribing
_
don't know why it's not working, but it was definitely added to core with d7:
http://drupal.org/node/224333#jquery_once
Subscribe. I have the same
Subscribe.
I have the same error when using drupal_add_js()
Same issue, had this appear
Same issue, had this appear out of nowhere.
subscribe
subscribe
ditto.
ditto.
My problem looks like it was
My problem looks like it was coming from the jQuery Update module. Turned that off and things seem to be working again.
Error was elsewhere
I had the same error reported in my Firebug console, but the real problem was that I had an error in the HTML I was creating. That caused the js files to not load properly. I turned off the toolbar module, and got an error that I traced back to the typo (missed a quote). Fixed that typo, re-enabled the toolbar module, and everything is good.
I have same issue when I use jQuery 1.7.2
In my case I found the root issue is that current Drupal 7 core is built on jQuery 1.4, and Once plugin seems only have a version compabible upto jQuery 1.4.x. So this problem occurs when I load jQuery 1.7.2. Unfortunately I have a widget plugin which requires higher version. In addition, Drupal.js is using jQuery 1.4, and I have to call my widget within behavior. I am using an ugly solution now, have two version of jQuery, 1.4 and 1.7.2 on same page, using the $.noConflict method of jQuery. If anyone have a better solution upgrading jQuery, I want to learn it too.
subscribe
subscribe
Problem Diagnosis and Possible Fixes
I had this problem today and have since rectified it.
This error happens when the Drupal core tries to run the jQuery function once() and it isn't found. Once() is not a native jQuery function but expanded into jQuery by Drupal in the client.
Diagnosis?
The problem happens in one of the following circumstances:
Fixes
The first case may arise if you've hacked the core. Or if you are diliberately not including javascript files that drupal would otherwise include.
The second case may arise if you are re-initialising the jQuery object. This is the mistake I was making earlier today. I was doing this:
drupal_add_js('http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js', array('every_page'=>FALSE));to upgrade my version of jQuery to 1.8.0 so the libraries I was using would work. Don't do that, use the jQuery update module.
If the third case arises... you're in real trouble.
I hope this helps.
Ya same issue here :(
Ya same issue here :(
subscribe. P.S. tried to
subscribe.
P.S. tried to solve problem with this
https://drupal.org/node/1793366
still have
This is probably happening
This is probably happening because you are calling $.once() before it has been loaded.
$.once() should not be called before Drupal has loaded. If you are using the jQuery $(document).ready() function, you need to switch to Drupal.behaviors. Here is a skeleton you can use:
Drupal.behaviors will actually be attached multiple times on a page, and by using $.once(), you can ensure that your code is only fired once.
Contact me to contract me for D7 -> D10/11 migrations.
Yet again
For me it happens when I try to add an (whatever) action within Rules, Drupal 7.24 & Rules 7.x-2.6. At this point, where this issue arises, there is no custom javascript loaded and no theme override is happening (Theme::Seven).
As an ugly hack, I found the following "solution" reading the previous posts. When I want to add a new Rules::action I disable temporarily the jQuery update module (7.x-2.3) and everything works smooth (within Rules) :(
(For crawlers) the error that consoles shows:
Problem has been checked on both Chrome and Opera (Linux Mint)
--
http://1024.gr - Programming by nature
Check your page source to
Check your page source to make sure that you don't load multile jquery version. If you must have to do it, please use conflict elimination.