Skip to content

Instantly share code, notes, and snippets.

@meirish
Created November 16, 2011 15:33
Show Gist options
  • Save meirish/1370363 to your computer and use it in GitHub Desktop.
Save meirish/1370363 to your computer and use it in GitHub Desktop.
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