Skip to content

Uncaught SyntaxError: Invalid regular expression: /(^|\.)rails(\.|$)/: Stack overflow #490

Open
@JohnMerlino2

Description

@JohnMerlino2

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions