Skip to content

Commit

Permalink
hobo-rapid javascript -- only do resetForm on success. Add new onSucc…
Browse files Browse the repository at this point in the history
…ess callback to Hobo.ajaxRequest
  • Loading branch information
tslocke committed Jun 23, 2008
1 parent 89d43d2 commit 699e67c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions hobo/rails_generators/hobo_rapid/templates/hobo-rapid.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,15 @@ var Hobo = {

Hobo.showSpinner(options.message, options.spinnerNextTo)
var complete = function() {
if (form && options.resetForm) form.reset();
Hobo.hideSpinner();

if (options.onComplete)
options.onComplete.apply(this, arguments)
if (options.onComplete) options.onComplete.apply(this, arguments)
if (form && options.refocusForm) Form.focusFirstElement(form)
Event.addBehavior.reload()
}
var success = function() {
if (options.onSuccess) options.onSuccess.apply(this, arguments)
if (form && options.resetForm) form.reset();
}
if (options.method && options.method.toLowerCase() == "put") {
delete options.method
params.push("_method=PUT")
Expand All @@ -122,7 +123,7 @@ var Hobo = {
}
}

new Ajax.Request(url, Object.merge(options, { parameters: params.join("&"), onComplete: complete }))
new Ajax.Request(url, Object.merge(options, { parameters: params.join("&"), onComplete: complete, onSuccess: success }))
},

hide: function() {
Expand Down

0 comments on commit 699e67c

Please sign in to comment.