Created
March 22, 2012 20:58
-
-
Save krusty/2164463 to your computer and use it in GitHub Desktop.
blocking view
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
View: Backbone.View.extend({ | |
initialize: function (options) { | |
if (typeof this.smb_initialize === "function") { | |
this.smb_initialize(options); | |
} | |
this.block_options = this.block_options || {}; | |
this.block_options.element = this.block_options.element || this.$el; | |
this.block_options.object = this.block_options.object || | |
this.object; | |
var object = this[this.block_options.object]; | |
if (object) { | |
object.on('fetching', this.block, this); | |
object.on('reset change add done', this.unblock, this); | |
object.on('post_action:change_class', this.change_class, this); | |
} | |
Backbone.View.prototype.initialize.call(this); | |
}, | |
change_class: function(post_action, original_post_action) { | |
this.$el | |
.removeClass(original_post_action.from_class) | |
.addClass(original_post_action.to_class); | |
}, | |
block: function () { | |
this.block_options.element.block(); | |
}, | |
unblock: function () { | |
this.block_options.element.unblock(); | |
}, | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment