regarding debounce debounces.

This commit is contained in:
Dominik Maier 2014-03-24 01:18:36 +01:00
parent dcbd55a864
commit f66e210c73

View file

@ -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())