I am getting the following Javascript error in my console whenever I try to edit a view:
Error: $form.once is not a function
Source File: sites/all/modules/views/js/views-admin.js?m1aqfl
Line: 160
It happens the first time in any edit that I try to load a Views overlay box (ie, to configure a field, add/remove filters etc.) and stops the overlay appearing, stopping me editing my view.
The error came up a while ago and I circumvented it (in the end) by cloning the view, and then removing the erroneous one, which allowed me to edit the "new" view alright again.. but it now appears to be the case on a couple of my other views too, so I thought I best report it?
I do have a lot of content, and contrib modules on this site, but as the error is actually coming from a JS file within the Views module, I feel this problem is probably contained (to some degree) within Views 3.
Comments
Comment #1
dawehnerThis seems to be a duplicate of #1504560: Multiple Ajax Pagers Break jQuery Once
Comment #2
Manindar commentedI'm getting these above error for me any one can guide me i'm struggle 3days from this error
Comment #3
LucasLLLS commentedI was having the same issue, then i have changed my jQuery version from 1.10 to 1.8 and it solved the problem.
Comment #4
Laurent Fauvel commentedI had a similar problem, I have seen many comment reporting the change of jquery version miraculously resolved their issue but I think the problem was coming from the PHP extension suhosin default configuration, and changing version was just allowing them to enter the default limit of suhosin.
Background :
When an ajax call is sent, Drupal will also send the page state (listing css, js, ...) so it doesn't send again js and css files allready loaded, you can see them in the $_POST sent to the server.
The problem :
The PHP extension Suhosin, by default, limits the number of characters in an index of an array in $_POST variables at 64 :
https://suhosin.org/stories/configuration.html#suhosin-post-max-array-in...
And Drupal send the ajax page state as an array, if you have jquery update activated then the index can be quite long for some of the js files since it is the file path : sites/all/modules/contrib/jquery_update/replace/1.10/jquery.min.js wich is over 64 character so it will be blocked by suhosin
But on the other hand the path to jquery.once.js is small and will get to the PHP engine.
So you end having Drupal thinking the page has jquery.once.js loaded allready but is missing jquery.min.js and then it will send in the ajax response the jquery.min.js file to reload it (and erase custom function added by jquery.once.js wich provoked the error $form.once is not a function)
The solution :
Change the value to the suhosin parameter blocking these index :
php_admin_value[suhosin.post.max_array_index_length] = "256"
php_admin_value[suhosin.get.max_array_index_length] = "256"
php_admin_value[suhosin.request.max_array_index_length] = "256"
(maybe I am covering more than needed with get/request)
256 characters seems to be covering all needs on my project.
Comment #5
coalvilledave commentedI had this error after creating a new view. I tried changing the JQuery version and Suhosin was not installed so it wasn't that.
After hours of frustration it turned out to be that I had set the maximum number of pager items to 9999. When I set this back to a smaller number (9 in this case) the edit view ui started working properly again.
Hope this saves someone a headache!
Comment #6
fineartist99 commentedI adjusted these settings to the suhosin parameters and it corrected the issue (actually I had contacted my host to adjust the settings)
php_admin_value[suhosin.post.max_array_index_length] = "256"
php_admin_value[suhosin.get.max_array_index_length] = "256"
php_admin_value[suhosin.request.max_array_index_length] = "256"
Comment #7
Cosy commentedBoom. I knew it must SUHOSIN !
I installed it a few days ago to improve some bugs i was having in a magento install but evidently failed to realise how much effect it would have on other sites i host.
I was getting the same jquery.once is not a function error in my admin pages for a roomify site I built (use adminimal theme) when it was making ajax calls in a form.
updated max_array_index_length to 1000 to be safe as well as max_array_length and errors have gone.
Well done Laurent..
Comment #8
dunot commentedTurning off Tampermonkey (extension in my browser) for the site helped me.
The extension loads another JQuery instance.