mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-04-27 06:23:41 -04:00
regarding codecombat/codecombat#655 -> adds asynchronous name checking that actually works.
This commit is contained in:
parent
0dee3d042f
commit
dcbd55a864
1 changed files with 13 additions and 1 deletions
|
@ -11,6 +11,7 @@ module.exports = class WizardSettingsModal extends View
|
|||
closesOnClickOutside: false
|
||||
|
||||
events:
|
||||
'keyup #wizard-settings-name': 'onNameChange'
|
||||
'click #wizard-settings-done': 'onWizardSettingsDone'
|
||||
|
||||
afterRender: ->
|
||||
|
@ -18,7 +19,18 @@ module.exports = class WizardSettingsModal extends View
|
|||
view = new WizardSettingsView()
|
||||
@insertSubView view
|
||||
|
||||
onWizardSettingsDone: ->
|
||||
onNameChange: =>
|
||||
forms.clearFormAlerts(@$el)
|
||||
checkNameExists = =>
|
||||
name = $('#wizard-settings-name').val()
|
||||
success = (id) =>
|
||||
forms.clearFormAlerts(@$el)
|
||||
forms.applyErrorsToForm(@$el, {property:'name', message:'is already taken'}) if id and id isnt me.id
|
||||
$.ajax("/db/user/#{name}/nameToID", {success: success})
|
||||
_.debounce(checkNameExists, 300)()
|
||||
|
||||
|
||||
onWizardSettingsDone: =>
|
||||
me.set('name', $('#wizard-settings-name').val())
|
||||
forms.clearFormAlerts(@$el)
|
||||
res = me.validate()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue