Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

fix if this.model is null #446

Open
wants to merge 1 commit into from

1 participant

@flyerhzm

it's a special case that this.model is null in IE9, I'd like to check if
this.model is defined, then use this.model.prototype.

@flyerhzm flyerhzm fix if this.model is null
it's a special case that this.model is null in IE9, I'd like to check if
this.model is defined, then use this.model.prototype.
a5913a1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 20, 2014
  1. @flyerhzm

    fix if this.model is null

    flyerhzm authored
    it's a special case that this.model is null in IE9, I'd like to check if
    this.model is defined, then use this.model.prototype.
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 5 deletions.
  1. +5 −5 backbone-relational.js
View
10 backbone-relational.js
@@ -1847,7 +1847,7 @@
var set = Backbone.Collection.prototype.__set = Backbone.Collection.prototype.set;
Backbone.Collection.prototype.set = function( models, options ) {
// Short-circuit if this Collection doesn't hold RelationalModels
- if ( !( this.model.prototype instanceof Backbone.RelationalModel ) ) {
+ if ( !this.model || !( this.model.prototype instanceof Backbone.RelationalModel ) ) {
return set.apply( this, arguments );
}
@@ -1900,7 +1900,7 @@
var remove = Backbone.Collection.prototype.__remove = Backbone.Collection.prototype.remove;
Backbone.Collection.prototype.remove = function( models, options ) {
// Short-circuit if this Collection doesn't hold RelationalModels
- if ( !( this.model.prototype instanceof Backbone.RelationalModel ) ) {
+ if ( !this.model || !( this.model.prototype instanceof Backbone.RelationalModel ) ) {
return remove.apply( this, arguments );
}
@@ -1932,7 +1932,7 @@
options = _.extend( { merge: true }, options );
var result = reset.call( this, models, options );
- if ( this.model.prototype instanceof Backbone.RelationalModel ) {
+ if ( this.model && this.model.prototype instanceof Backbone.RelationalModel ) {
this.trigger( 'relational:reset', this, options );
}
@@ -1946,7 +1946,7 @@
Backbone.Collection.prototype.sort = function( options ) {
var result = sort.call( this, options );
- if ( this.model.prototype instanceof Backbone.RelationalModel ) {
+ if ( this.model && this.model.prototype instanceof Backbone.RelationalModel ) {
this.trigger( 'relational:reset', this, options );
}
@@ -1960,7 +1960,7 @@
var trigger = Backbone.Collection.prototype.__trigger = Backbone.Collection.prototype.trigger;
Backbone.Collection.prototype.trigger = function( eventName ) {
// Short-circuit if this Collection doesn't hold RelationalModels
- if ( !( this.model.prototype instanceof Backbone.RelationalModel ) ) {
+ if ( !this.model || !( this.model.prototype instanceof Backbone.RelationalModel ) ) {
return trigger.apply( this, arguments );
}
Something went wrong with that request. Please try again.