mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-04-27 14:33:59 -04:00
Merge pull request #441 from yangshun/level-editor-freeze
Redirect to level editor only after modal hidden event is triggered. Fixes #438 and #439.
This commit is contained in:
commit
b5ff264ad0
1 changed files with 10 additions and 4 deletions
|
@ -24,6 +24,7 @@ module.exports = class ThangTypeHomeView extends View
|
|||
'click button.new-model-submit': 'makeNewModel'
|
||||
'submit form': 'makeNewModel'
|
||||
'shown.bs.modal #new-model-modal': 'focusOnName'
|
||||
'hidden.bs.modal #new-model-modal': 'onModalHidden'
|
||||
|
||||
getRenderData: ->
|
||||
c = super()
|
||||
|
@ -85,16 +86,21 @@ module.exports = class ThangTypeHomeView extends View
|
|||
res = model.save()
|
||||
return unless res
|
||||
|
||||
modal = @$el.find('.modal')
|
||||
modal = @$el.find('#new-model-modal')
|
||||
forms.clearFormAlerts(modal)
|
||||
@showLoading(modal.find('.modal-body'))
|
||||
res.error =>
|
||||
@hideLoading()
|
||||
forms.applyErrorsToForm(modal, JSON.parse(res.responseText))
|
||||
that = @
|
||||
res.success ->
|
||||
modal.modal('hide')
|
||||
base = document.location.pathname[1..] + '/'
|
||||
app.router.navigate(base + (model.get('slug') or model.id), {trigger:true})
|
||||
that.model = model
|
||||
modal.modal('hide')
|
||||
|
||||
onModalHidden: ->
|
||||
# Can only redirect after the modal hidden event has triggered
|
||||
base = document.location.pathname[1..] + '/'
|
||||
app.router.navigate(base + (@model.get('slug') or @model.id), {trigger:true})
|
||||
|
||||
focusOnName: ->
|
||||
@$el.find('#name').focus()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue