Improved form handling of generic objects.

This commit is contained in:
Martin Edenhofer 2012-10-14 15:45:31 +02:00
parent f4fee25a62
commit 039cdb8f38
2 changed files with 10 additions and 9 deletions

View file

@ -574,12 +574,14 @@ class App.ControllerForm extends App.Controller
@disable: (form) ->
console.log 'disable...', $(form.target).parent()
$(form.target).parent().find('button').attr('disabled', true)
$(form.target).parent().find('[type="submit"]').attr('disabled', true)
$(form.target).parent().find('[type="reset"]').attr('disabled', true)
@enable: (form) ->
console.log 'enable...', $(form).parent()
$(form).parent().find('button').attr('disabled', false)
$(form).parent().find('[type="submit"]').attr('disabled', false)
$(form).parent().find('[type="reset"]').attr('disabled', false)

View file

@ -27,16 +27,10 @@ class App.ControllerGenericNew extends App.ControllerModal
@log 'submit'
e.preventDefault()
params = @formParam(e.target)
###
for num in [1..199]
user = new User
params.login = 'login_c' + num
user.updateAttributes(params)
return false
###
object = new @genericObject
object.load(params)
# validate
errors = object.validate()
if errors
@ -44,6 +38,9 @@ class App.ControllerGenericNew extends App.ControllerModal
@formValidate( form: e.target, errors: errors )
return false
# disable form
@formDisable(e)
# save object
object.save(
success: =>
@ -97,7 +94,9 @@ class App.ControllerGenericEdit extends App.ControllerModal
@formValidate( form: e.target, errors: errors )
return false
@log 'save....'
# disable form
@formDisable(e)
# save object
@item.save(
success: =>