jquery-ujs
jquery-ujs copied to clipboard
Uncaught SyntaxError: Invalid regular expression: /(^|\.)rails(\.|$)/: Stack overflow
I have a select element which has a remote: true to my contacts controller. However, if one of the options is selected, then I want to cancel that remote call and invoke a different controller instead. In the ajax:beforeSend event, I check if the specific option is selected and then return false:
if( $select.val() == "1" ){
$('.loading').hide();
$select.find('option:selected') .trigger('change.rails');
return false;
The return false works and the original ajax call is stopped. However, the selected option looks like this:
<option data-url="/contacts/edit_multiple" data-remote="true" data-type="html" data-method="post" data-params="filterable=Lead" data-toggle="modal" data-target="filterEdit" value="1">Edit/Delete Filter</option>
And when I trigger the change.rails event on it, I get the following error:
Uncaught SyntaxError: Invalid regular expression: /(^|.)rails(.|$)/: Stack overflow
Anyone know why this error occurs?
I have the same problem it looks like a jQuery issue