mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-03-24 11:50:58 -04:00
Redirect to level editor only after modal hidden event is triggered. Fixes #438.
This commit is contained in:
parent
e20e9d68cf
commit
8af62d53cd
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
Reference in a new issue