Skip to content

Commit

Permalink
#9 Including option 'attr' for attribution of view in the container
Browse files Browse the repository at this point in the history
  • Loading branch information
tracend committed Nov 12, 2012
1 parent 2b15c95 commit 928dc2d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build/backbone.app-min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions build/backbone.app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**@license
* backbone.app <>
* Version: 0.6.0 (Sun, 11 Nov 2012 02:16:59 GMT)
* Version: 0.6.0 (Mon, 12 Nov 2012 02:03:37 GMT)
* License:
*/
(function(_, Backbone) {
Expand Down Expand Up @@ -171,8 +171,13 @@
// find the data
this.data = this.model || this.collection || null;
//
//_.extend({name : 'moe'}, {age : 50});
if( ! this.options.type ) this.options.type = "default";
// #9 optionally add a reference to the view in the container
if( this.options.attr ) {
$(this.el).attr("data-view", this.options.attr );
} else {
$(this.el).removeAttr("data-view");
}
// compile
var html = this.options.html || null;
var options = {};
Expand Down Expand Up @@ -234,10 +239,13 @@
Template = Backbone.Model.extend({
initialize: function(html, options){
_.bindAll(this, 'fetch','parse');
// fallback for options
var opt = options || (options={});
if( !_.isEmpty(html) ){
this.set( "default", this.compile( html ) );
this.trigger("loaded");
}
//if( !_.isUndefined( options.url ) && !_.isEmpty( options.url ) ){
if( options.url ){
this.url = options.url;
this.fetch();
Expand Down
2 changes: 1 addition & 1 deletion lib/app.template.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
initialize: function(html, options){
_.bindAll(this, 'fetch','parse');
// fallback for options
options || (options={});
var opt = options || (options={});
if( !_.isEmpty(html) ){
this.set( "default", this.compile( html ) );
this.trigger("loaded");
Expand Down
7 changes: 6 additions & 1 deletion lib/app.view.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@
// find the data
this.data = this.model || this.collection || null;
//
//_.extend({name : 'moe'}, {age : 50});
if( ! this.options.type ) this.options.type = "default";
// #9 optionally add a reference to the view in the container
if( this.options.attr ) {
$(this.el).attr("data-view", this.options.attr );
} else {
$(this.el).removeAttr("data-view");
}
// compile
var html = this.options.html || null;
var options = {};
Expand Down

0 comments on commit 928dc2d

Please sign in to comment.