diff --git a/src/jquery.maskMoney.js b/src/jquery.maskMoney.js index 1d74bed..889ac5f 100644 --- a/src/jquery.maskMoney.js +++ b/src/jquery.maskMoney.js @@ -49,8 +49,8 @@ }); }, - init : function (settings) { - settings = $.extend({ + init : function (parameters) { + parameters = $.extend({ prefix: "", suffix: "", affixesStay: true, @@ -59,13 +59,14 @@ precision: 2, allowZero: false, allowNegative: false - }, settings); + }, parameters); return this.each(function () { - var $input = $(this), + var $input = $(this), settings, onFocusValue; // data-* api + settings = $.extend({}, parameters); settings = $.extend(settings, $input.data()); function getInputSelection() { diff --git a/test/data_dash_test.js b/test/data_dash_test.js index 4de6e1b..cdf2338 100644 --- a/test/data_dash_test.js +++ b/test/data_dash_test.js @@ -13,6 +13,15 @@ test("configuring a setting that isn't a single word", function() { input.attr("data-allow-zero", "true"); input.maskMoney(); input.val("0"); - input.trigger("mask").trigger("blur"); + input.trigger("mask"); equal(input.val(), "R$0,00", "it works by using dashes-pattern instead of camelCase"); }); + +test("allow to configure multiple fields using data-* attributes", function() { + var input = $(".multiple-dash").maskMoney(); + input.val("12345678"); + input.trigger("focus"); + equal($("#input3").val(), "R$12.345.678,00", "configure maskMoney using data-* attributes"); + equal($("#input4").val(), "U$12,345,678.00", "configure maskMoney using data-* attributes"); +}); + diff --git a/test/index.html b/test/index.html index befd8bd..9184b15 100644 --- a/test/index.html +++ b/test/index.html @@ -22,7 +22,8 @@