Skip to content

Commit

Permalink
Merge pull request vitalets#745 from ins429/dev
Browse files Browse the repository at this point in the history
use strict eq(===) to check on the new value equals to the old value, vitalets#744
  • Loading branch information
tofutim committed Nov 10, 2015
2 parents 054e40b + 9a82044 commit d33965e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/editable-form/editable-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc.

//if value not changed --> trigger 'nochange' event and return
/*jslint eqeq: true*/
if (!this.options.savenochange && this.input.value2str(newValue) == this.input.value2str(this.value)) {
if (!this.options.savenochange && this.input.value2str(newValue) === this.input.value2str(this.value)) {
/*jslint eqeq: false*/
/**
Fired when value not changed but form is submitted. Requires savenochange = false.
Expand Down
18 changes: 16 additions & 2 deletions test/unit/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,20 @@ $(function () {
ok(p.find('input').length, 'input exists');
equal(p.find('input').val(), 'qwe', 'default text not set as element not empty');
});


test("should able to submit a value which changed 0 to ''(empty string)", function () {
var e = $('<a href="#" data-name="text1"></a>').appendTo('#qunit-fixture').editable({
value: '0'
});

//empty text
e.click();
var p = tip(e);
equal(p.find('input').val(), '0', 'text value is 0 ok');
p.find('input').val('');
p.find('form').submit();
e.click();
equal(p.find('input').val(), '', 'text changed to \'\' ok');
});

});
});

0 comments on commit d33965e

Please sign in to comment.