Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue when select 'name' attribute contains spaces and enclosed in round bracket #5436

Closed
bharathD29 opened this issue Jan 7, 2019 · 1 comment

Comments

@bharathD29
Copy link

bharathD29 commented Jan 7, 2019

For example I created a form select using,

<select name="(Second level with_spaced_words)" tabindex="-1" >
	<option value="1000">Third level first entry</option>
	<option value="2000">Third level second entry</option>
	<option value="3000">Third level third entry</option>
</select>

Then I initialization select()

$(document).ready(function() {
	 $('select').select2();
});

on clicking the select now, the drop-down opens and it never closes.

then when I looked on the web browser console, Found the below error.

Uncaught SyntaxError: Invalid regular expression: /(^|\.)select2\.(?:.*\.|)select2-(Second(\.|$)/: Unterminated group
    at new RegExp (<anonymous>)
    at Object.remove (jquery.js:5024)
    at HTMLBodyElement.<anonymous> (jquery.js:5493)
    at Function.each (jquery.js:368)
    at jQuery.fn.init.each (jquery.js:157)
    at jQuery.fn.init.off (jquery.js:5492)
    at d._detachCloseHandler (select2.min.js:1)
    at e.<anonymous> (select2.min.js:1)
    at e.d.invoke (select2.min.js:1)
    at e.d.trigger (select2.min.js:1)

I tried to eliminate the spaces. The results are normal.

<select name="(Second_level_with_spaced_words)" tabindex="-1" >
	<option value="1000">Third level first entry</option>
	<option value="2000">Third level second entry</option>
	<option value="3000">Third level third entry</option>
</select>

NOTE: The issue occurs when the name value is having spaces and is enclosed in round brackets.
For Example: Refer to the fiddle

@stale
Copy link

stale bot commented Mar 13, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the status: stale label Mar 13, 2019
@stale stale bot closed this as completed Mar 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant