Merge remote branch 'tomk/729-retain-input-on-failure'
This commit is contained in:
commit
429087ef83
4 changed files with 32 additions and 4 deletions
|
|
@ -98,10 +98,14 @@ jQuery(function ($) {
|
|||
$('form[data-remote]').live('submit', function (e) {
|
||||
$(this).callRemote();
|
||||
e.preventDefault();
|
||||
$(this).clearForm();
|
||||
$(this).focusout();
|
||||
});
|
||||
|
||||
$('form[data-remote]').live('ajax:success', function (e) {
|
||||
$(this).clearForm();
|
||||
$(this).focusout();
|
||||
});
|
||||
|
||||
|
||||
$('a[data-remote],input[data-remote]').live('click', function (e) {
|
||||
$(this).callRemote();
|
||||
e.preventDefault();
|
||||
|
|
|
|||
|
|
@ -11,12 +11,13 @@
|
|||
|
||||
beforeEach(function() {
|
||||
$('#jasmine_content').empty();
|
||||
spec.clearLiveEventBindings();
|
||||
// NOTE Commented (as well as in afterEach) to keep the listeners from rails.js alive.
|
||||
//spec.clearLiveEventBindings();
|
||||
jasmine.Clock.useMock();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
spec.clearLiveEventBindings();
|
||||
//spec.clearLiveEventBindings();
|
||||
expect(spec.loadFixtureCount).toBeLessThan(2);
|
||||
spec.loadFixtureCount = 0;
|
||||
});
|
||||
|
|
|
|||
22
spec/javascripts/rails-spec.js
Normal file
22
spec/javascripts/rails-spec.js
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
describe("rails", function() {
|
||||
describe("remote forms", function() {
|
||||
beforeEach(function() {
|
||||
$("#jasmine_content").html(
|
||||
'<form accept-charset="UTF-8" id="form" action="/status_messages" data-remote="true" method="post">' +
|
||||
'<textarea id="status_message_message" name="status_message[message]">Some status message</textarea>' +
|
||||
'<input type="submit">' +
|
||||
'</form>'
|
||||
);
|
||||
});
|
||||
it("should retain form values if ajax fails", function() {
|
||||
$('#form').trigger('ajax:failure');
|
||||
expect($('#status_message_message').val()).not.toEqual("");
|
||||
});
|
||||
it("should clear form on ajax:success", function() {
|
||||
$('#form').trigger('ajax:success');
|
||||
|
||||
expect($('#status_message_message').val()).toEqual("");
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -25,6 +25,7 @@ src_files:
|
|||
- public/javascripts/view.js
|
||||
- public/javascripts/stream.js
|
||||
- public/javascripts/validation.js
|
||||
- public/javascripts/rails.js
|
||||
# stylesheets
|
||||
#
|
||||
# Return an array of stylesheet filepaths relative to src_dir to include before jasmine specs.
|
||||
|
|
|
|||
Loading…
Reference in a new issue