mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-04-27 06:23:41 -04:00
regarding codecombat/codecombat#655 debounce debounces.
This commit is contained in:
parent
dcbd55a864
commit
f66e210c73
1 changed files with 10 additions and 9 deletions
|
@ -10,6 +10,10 @@ module.exports = class WizardSettingsModal extends View
|
|||
template: template
|
||||
closesOnClickOutside: false
|
||||
|
||||
constructor: (options) ->
|
||||
@onNameChange = _.debounce(@checkNameExists, 200)
|
||||
super options
|
||||
|
||||
events:
|
||||
'keyup #wizard-settings-name': 'onNameChange'
|
||||
'click #wizard-settings-done': 'onWizardSettingsDone'
|
||||
|
@ -19,16 +23,13 @@ module.exports = class WizardSettingsModal extends View
|
|||
view = new WizardSettingsView()
|
||||
@insertSubView view
|
||||
|
||||
onNameChange: =>
|
||||
checkNameExists: =>
|
||||
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)()
|
||||
|
||||
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})
|
||||
|
||||
onWizardSettingsDone: =>
|
||||
me.set('name', $('#wizard-settings-name').val())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue