Uncaught Error: Syntax error, unrecognized expression

438 views
Skip to first unread message

psy...@gmail.com

unread,
Sep 29, 2015, 2:29:42 AM9/29/15
to select2
Hi there,

Firstly I would like to thank the team for Select2 - it is an absolute pleasure to work with and has thus for suited all my needs for my project.

I do however have one little issue that I am hitting my head on:

I have a rigged my Select2 to fetch Suburb data from our server via Ajax.
Unfortunately there are a few suburb names with the character '&' in.
When the list displays, the '&' displays correctly. However when I select the item from the list, i receive an Uncaught Error: Syntax error, unrecognized expression: 'Suburb Name & Bla bla'.

My script looks as follows at the moment

select.select2(
{
ajax: {
url: ajaxUrl,
dataType: 'json',
delay: 250,
data: function(params) {
return {
countryId: 1,
query: params.term
};
},
processResults: function (data) {

var results = [];
for (var i = 0; i < data.Suburbs.length; i++) {

results.push({
id: data.Suburbs[i].Id,
text: data.Suburbs[i].DisplayName,
});
}

return {
results: results
};
},
cache: false
},
closeOnSelect: false,
scapeMarkup: function (markup) {


return markup;

},
minimumInputLength: 3,
multiple: true,
});


Are there any options or tricks that I can do to still keep the ampersand displaying in my list of choices and after selection?

Thanks in advance

Kevin Brown

unread,
Sep 29, 2015, 8:32:04 AM9/29/15
to select2

This is usually an issue triggered by a jQuery selector, and the solution is to properly escape it ahead of time. Do you have the full traceback so we can figure out what selector is causing the issue?

If you can also reproduce the issue in a jsbin, that would make it easier for us to later confirm that the issue was fixed.


--
You received this message because you are subscribed to the Google Groups "select2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to select2+u...@googlegroups.com.
To post to this group, send email to sel...@googlegroups.com.
Visit this group at http://groups.google.com/group/select2.
For more options, visit https://groups.google.com/d/optout.

psy...@gmail.com

unread,
Oct 6, 2015, 2:09:42 AM10/6/15
to select2, ke...@kevin-brown.com
Hi Kevin,

Many thanks for the reply, and my apologies that I have taken so long to respond. I found the cause to the problem. One of our devs extended jQuery.fn.extend: append function which was causing the sizzle error.

Thanks for your assistance!

Cheers

Toni Kroos

unread,
11:33 AM (5 hours ago) 11:33 AM
to select2
Coyyn is a modern fintech and digital-finance platform designed to empower freelancers, businesses, and individuals navigating the gig economy. It offers a secure multi-currency wallet that supports both fiat and cryptocurrencies, plus peer-to-peer payments and smart contract functionality. With a strong focus on blockchain, AI, and digital capital, Coyyn combines innovation, security, and accessibility for the future of finance.   
Reply all
Reply to author
Forward
0 new messages