Created
November 17, 2012 21:16
-
-
Save gorbach/4100381 to your computer and use it in GitHub Desktop.
Marionette.Region to show jquery dialog modal
This file contains 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
class Application extends Backbone.Marionette.Application | |
App = new EzBob.Application | |
App.addRegions | |
jqmodal: EzBob.JqModalRegion |
This file contains 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
class JqModalRegion extends Backbone.Marionette.Region | |
constructor: -> | |
@on 'view:show', @showModal, @ | |
@dialog = $('<div/>') | |
super() | |
el: 'fake' | |
getEl: (selector) -> | |
@dialog | |
showModal: (view)-> | |
view.on 'close', @.hideModal, @ | |
@dialog.dialog(view.jqoptions()) | |
@dialog.one 'dialogclose', => | |
@close() | |
hideModal: -> | |
@dialog.dialog('close') |
This file contains 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
class TestView extends Backbone.Marionette.View | |
constructor: -> | |
_.bindAll @ | |
super() | |
render: -> | |
@$el.html('<h2>Hello!</h2>') | |
jqoptions: -> | |
buttons: | |
'Ok': @onOk | |
'Cancel': @onCancel | |
modal: true | |
title: 'A test modal window' | |
onOk: -> | |
console.log 'ok' | |
@.close() | |
onCancel: -> | |
console.log 'cancel' | |
@.close() | |
close: -> | |
console.log 'view closed' | |
super() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment