Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8995531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:37:57+00:00 2026-06-15T23:37:57+00:00

I’m using BackboneJS, I have a got a collection which gets its data from

  • 0

I’m using BackboneJS, I have a got a collection which gets its data from an oData enabled WebAPI. While fetching the data, I pass in some extra parameters using oData $filter.

It looks a bit like this:

collection.fetch({
   data: $.param({ '$filter': 'Filter1 eq ' + filter.get('filter1') + 
                   ' and Filter2 eq ' + filter.get('filter2') }),
   //some more stuff...
})

I’m basically running through a wizard and building up this filter model along the way. Every value that comes out of this filter model is either a string value or an empty string. I have overridden the get method on the filter model to ensure that I get the right values out of it. Note that I add single quotes around the string value if it is not empty, if it is empty, I return a string value containing the word ‘null’.

var Filter = Backbone.Model.extend({        
    get: function (attributes, options) {
        var value = Backbone.Model.prototype.get.call(this, attributes, options);
        if (value == '') return 'null';
        else return "'" + value + "'";
    }
});

Say my model looks like this:

{filter1: 'filter1', filter2: 'filter2'}

Now if I fetch the collection in Chrome and Firefox, the request that is generated would look something like this:

replacedapiurl?%24filter=Filter1+eq+%27filter1%27+and+Filter2+eq+%27filter2%27

Which is perfectly fine and it works great in both Firefox and Chrome. The problem I am having is that in IE10 this does not work. For some reason the request that is generated looks like this:

replacedapiurl?%24filter=Filter1+eq+'+filter1+'+and+Filter1+eq+'+filter1+'

When I set it to IE9 mode, it does the same. When I set it to IE8 mode, it suddenly starts working.

Now I have tried using EncodeURI(), EncodeURIComponent(), escape() and adding ‘\’ in front of the single quotes, both inside my overridden get method and inside the $.param bit. But nothing works. Adding the ‘\’ does nothing, and all encoding does is encode the added ‘+’ sign like this:

replacedapiurl?%24filter=Filter1+eq+'%2520filter1%2520'+and+Filter1+eq+'%2520filter1%2520'

Which is also not what I am after.

Does anyone know why this is happening? Why is there a difference between IE browser versions with this behaviour? And how do I fix it? I need my single quotes converted to ‘%27’, preferably without having to write any browser specific code.

Edit: I just got someone to check things on IE9 and that works fine, so it is only when using IE10 -and when using IE10 in IE9 mode- that it doesn’t work.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T23:37:58+00:00Added an answer on June 15, 2026 at 11:37 pm

    OK, I thought this was beyond me, but in the end it wasn’t and I fixed it myself. Just in case it might help anyone in the future, I’ll explain why this was happening to me.

    The values in the filter object come out of a ‘select’, the ‘select’ is inside a backbone view, and the select is populated with a number of ‘option’ views. For some reason I had a template set up for my option view like so:

    <script type="text/template" id="option-template">
    <%=value%>
    </script>
    

    The line breaks in the HTML above made it so that the ‘option’ was rendered inside the ‘select’ with an extra space added on both sides of the value. Now the difference between all the other browsers I tried and IE10 seems to be that in IE10 those spaces in my option view do not get trimmed by jQuery’s val(), while in all the other browsers, they do get trimmed when reading the value of a ‘select’ with val(). This resulted in the extra space being turned into a ‘+’ sign on both sides of the value, like all the other spaces in the URL, and that was the problem! The single quote in itself does not need to be converted into %27, it should work either way, something I picked up from the answer on this question.

    I would not have had a problem had I written the template in one line like this:

    <script type="text/template" id="option-template"><%=value%></script>
    

    Anyway, I just got rid of the template all together and changed my option view to this:

    var optionView = Backbone.View.extend({
        tagName: "option",
        render: function () {
            this.$el.html(this.model.get('value'));
        }
    });
    

    And that fixed everything, no extra spaces around the options any more.

    I guess the lesson learned is that IE10 does not get rid of spaces around a value when you read a select box value with jQuery like so:

    var value = $('#id').val();
    

    In any other browser, if the option has spaces around it like ‘ value ‘, they will automatically be trimmed and value will be ‘value’, in IE10, this is not the case, and value will be ‘ value ‘.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a text area in my form which accepts all possible characters from
I am using jsonparser to parse data and images obtained from json response. When
I have an autohotkey script which looks up a word in a bilingual dictionary
I have an array which has BIG numbers and small numbers in it. I
I'm trying to select an H1 element which is the second-child in its group
I have thousands of HTML files to process using Groovy/Java and I need to
I have a view passing on information from a database: def serve_article(request, id): served_article
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.