Created
November 16, 2011 15:33
-
-
Save meirish/1370363 to your computer and use it in GitHub Desktop.
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
define([ | |
'jquery', | |
'underscore', | |
'backbone', | |
'ui' | |
], function($,_,Backbone, widgetListView){ | |
var DialogView = Backbone.View.extend({ | |
className: 'widget-slider', | |
events:{ | |
'touchstart .close':'closeDialog', | |
'click .close':'closeDialog' | |
}, | |
opts: { | |
draggable: false, | |
resizable: false, | |
modal: true | |
}, | |
initialize: function(options){ | |
var self = this; | |
if (options.template) { | |
// load the template | |
require(['text!templates/'+options.template], function(template){ | |
self.template = template; | |
if (options.model) self.obj = options.model; | |
if (options.collection) self.obj = options.collection.models; | |
self.render(); | |
}); | |
} | |
}, | |
render: function(){ | |
var context = { | |
obj: this.obj || {}, | |
_: _ | |
}, | |
markup = _.template(this.template, context); | |
$(this.el).html(markup).appendTo('body').dialog(this.opts); | |
return this; | |
}, | |
closeDialog: function(e){ | |
e.preventDefault(); | |
var $self = $(this.el); | |
$self.dialog('close'); | |
$self.remove(); | |
} | |
}); | |
return DialogView; | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment