Posted by Hodgekins on October 17, 2012 at 9:05pm
24 followers
Jump to:
| Project: | jQuery Update |
| Version: | 7.x-2.x-dev |
| Component: | Miscellaneous |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Issue Summary
Hi,
The ability to have conditional form #states was created in 7.14. See: http://drupal.org/node/1464758
When I use this functionality with jQuery Update I get a js error in the Google Chrome console:
Uncaught TypeError: Object 0 has no method 'charAt'
This is an example of code which causes the problem:
<?php
$form['example'] = array(
'#type' => 'textarea',
'#title' => 'Example Element',
'#states' => array(
'visible' => array(
':input[name="a_selector_element"]' => array(array('value' => '4'), array('value' => '5'))
)
)
);
?>I hope this bug report helps. If you need any more information let me know.
Cheers,
Ben
Comments
#1
I don't get that error but my states do not work when I use 1.7, but if I change back to 1.5 it works.
#2
me too
#3
Simply disabling the call to the local version of states worked for me.
jquery_update.module lines 96-98
#4
Commenting out lines 96-98 works for me, as well -- no idea yet if there are any side effects of this change.
#5
OK, found a side effect. With lines 96-98 commented out, the behavior of the URL Alias fields in the node edit form gets screwed up. When Automatic Alias is unchecked, the field for entering a manual alias is disabled.
#6
This has provided a certain measure of relief. I created a custom module using the code here:
http://drupal.stackexchange.com/questions/29576/how-can-i-disable-jquery...
This uses my selected update version of jQuery for non-admin pages, while using 1.5 for admin pages, preventing problems with states as long as the form appears on an admin page. It has a strange side effect of always displaying 1.5 as the selected version in the jQuery Update config form, but it does seem to work otherwise.
#7
this might help others. it helped me
http://drupal.org/node/1448490
#8
I encountered this error on the latest dev of jquery_update. states.js line 294 had:
while (this.name.charAt(0) == '!') {I simply changed it to:
while (this.name.toString().charAt(0) == '!') {#9
Yes, this removes the error, but states still do not work.
#10
Use http://drupal.org/project/jqmulti instead of Jquery Update.
Then core will be able to run on and old jquery alongside your new code running on a newrer version of jquery.
#11
This is actually fixed in the latest dev version. It has been fixed for a while. jquery_update replaces the actual drupal states.js file.
jqmulti is great, but I don't like having multiple jquery version :) I rather just fix the core issues. That being said if it works for other people please feel free to use it.
This is fixed, please test the latest dev version.
#12
@ericduran: sorry to reopen but i needed to apply the fix from #8 and i use latest dev :/
[edit] just be sure i checked: http://drupalcode.org/project/jquery_update.git/blob/refs/heads/7.x-2.x:... [/edit]
#13
I noticed this problem today. Updated to latest -dev and it fixed the page which was causing me problems.
@muschpusch what is the page / module which is causing you problems?
For me it was the "administration pages" of editing a "double_field". My problem is resolved.
#14
#13 didn't worked for me.
#15
@mattic, you're input isn't very helpful in moving this issue queue forward.
Any idea what page / module is causing you problems? If you'd like a more complete solution, you're going to have to provide some information.
#16
i get this on a node edit page. Different fields are on it... I will try reproduce in a simpler environment.
#17
sorry but i just realized that i had an older version of jquery_update in the sites/domain.com directory which was used instead of the more recent version in sites/all. Using the latest version indeed fixed the issue. Setting this to fixed since there was no other reply j0st
#18
Automatically closed -- issue fixed for 2 weeks with no activity.
#19
Sorry for reopening but this bug is still in 7.x.2x-dev.
It can be reproduced as follows:
You will notice that the conditional field will not fire and chrome will show this error in the console: Uncaught TypeError: Object 0 has no method 'charAt'.
Commenting out the following code will partially solve the problem:
// Replace files for jQuery 1.7 and upif (version_compare($version, '1.7', '>=')) {
$javascript['drupal.states']['js']['misc/states.js']['data'] = $path . '/replace/misc/1.7/states.js';
}
After deleting or commenting out the code above, a new error will show in Chrome's console: Uncaught TypeError: Cannot read property 'length' of undefined
Hope this helps tracking the issue.
Thank you for this great module!
#20
#21
Patch over at #1448490: fix states.js upstream and remove the overwrite in jQuery Update
#22
Still having same problem with latest dev. My scenario is essentially identical to jmartinez's.