0

This function is working correctly in Firefox but not IE 11. I believe the culprit is:

event = String(data.model.attributes.eventToRaise);

I know through a bunch of logging (which I removed for presentation here) that I'm getting into the first else branch correctly, but that the comparison to 'AAA' and 'BBB' aren't working correctly in IE. Logging the contents of 'event' in Firefox shows me a string but in IE console it's a pointer. I've tried a few different things (.toString(), "" + event), all of which worked in FF but not IE.

The context is Backbone with Marionette, this function is being called on click events from different places, and the code is supposed to determine which event originated the call.

       showPanel: function (data) {
            event = String(data.model.attributes.eventToRaise);
            if (event === this.lastEvent) {
                //do something
            }
            else {
                var view = NaN;

                if (event === 'AAA') {
                    //whatever
                }
                else if (event === 'BBB') {
                    //whatever else
                }

            this.lastEvent = event;
        }

edit: 'var event = String(data.model.attributes.eventToRaise);' solved the issue

Nathan Spears
  • 1,657
  • 8
  • 23
  • 31
  • Well, what are you setting `eventToRaise` to? – Jan Aug 25 '15 at 18:54
  • (1) Why `event` rather than `var event`? (2) Why `String(data.model.attributes.eventToRaise)` rather than just `data.model.attributes.eventToRaise`? – mu is too short Aug 25 '15 at 19:20
  • @muistooshort var event did it, thanks. String() because it wasn't acting like a string so I was trying to be more explicit, but it was unnecessary. – Nathan Spears Aug 25 '15 at 20:25

2 Answers2

0

You could try the following:

showPanel: function (data) {
    event = new String(data.model.attributes.eventToRaise);
    if (event === this.lastEvent) {
        //do something
    }
    else {
        var view = NaN;

        if (event.indexOf("AAA")) {
            //whatever
        }
        else if (event.indexOf("BBB")) {
            //whatever else
        }

    this.lastEvent = event;
}
mojoaxel
  • 1,440
  • 1
  • 14
  • 19
0
var event = data.model.attributes.eventToRaise;

solved the issue.

Nathan Spears
  • 1,657
  • 8
  • 23
  • 31