Skip to content

Event relation:change is triggered when it shouldn't #428

Open
floo51 opened this Issue Dec 31, 2013 · 4 comments

5 participants

@floo51
floo51 commented Dec 31, 2013

When setting nest model values to same current values, relation:change event is triggered. And unless i'm mistaken, it shouldn't.

It seems pretty similar to #140.

Code example

var Phone = Backbone.RelationalModel.extend();

var Contact = Backbone.RelationalModel.extend({
    relations: [
        {
            type: Backbone.HasMany,
            key: 'phones',
            relatedModel: Phone,
            reverseRelation: {
                key: 'contact'
            }
        }
    ]
});

var contactData = {
    "id": "contact-2",
    "phones": []
};

var contact = new Contact(contactData);

contact.on('change', function() {
    console.log( 'contact:change');
});

contact.on('all', function(evt) {
    console.log( 'contact:' + evt );
});

contact.set(contactData);

Js fiddle to demonstration

@paulosborne

+1

@Muon
Muon commented Jul 11, 2014

Definitely an issue here.

@dminkovsky

Doesn't seem to be an issue anymore. Check out the fiddle. Only the internal relational event is fired, which happens when you set a relational key. But the public change does not get fired.

@floo51
floo51 commented Sep 15, 2014

The public change does not get fired either when it should then.
http://jsfiddle.net/floo51/2xumV/5/

It doesn't make sense, either the event is not internal and is always triggered as stated in the original issue description or it is internal and then some event definitely lacks on the first end of the relation.

@bpatram bpatram added the bug label Mar 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.