如何修复jQuery maskMoney-未应用遮罩

时间:2019-02-09 15:24:08

标签: spring-mvc jquery-plugins thymeleaf

我想在使用jquery.maskMoney插件获得焦点时将遮罩应用于某些输入元素。但是,当它聚焦时,遮罩就没有了。

代码

brewer.js (注意:.js十进制将输入元素中的maskMoney以及.js普通字符应用于整数)

$(function() {
    var decimnal = $('.js-decimal');
    decimal.maskMoney();

    var plain = $('.js-plain');
    plain.maskMoney({ precision: 0 });
});

CadastroCerveja.html

<!DOCTYPE html>
<html lang="pt" xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
      layout:decorator="'layout/LayoutPadrao'">

<body>
    <form method="POST" th:object="${cerveja}" class="form-vertical  js-form-loading">

         <div class="row">
            <div class="col-sm-3 form-group">
                <label for="preco">Preço</label>
                <div class="input-group">
                    <input id="preco" type="text" class="form-control  js-decimal"/>
                </div>
            </div>

        </div>

    </form>

</body>

</html>

LayoutPadrao.html

<!DOCTYPE html>
<html lang="pt" xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
<head>
    <meta charset="UTF-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="viewport" content="width=device-width, initial-scale=1"/>

    <title>Brewer</title>

    <link rel="stylesheet" type="text/css" th:href="@{/layout/stylesheets/vendors.min.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/layout/stylesheets/algaworks.min.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/layout/stylesheets/application.css}"/>


</head>

<body>

...

    <script th:src="@{/layout/javascripts/vendors.min.js}"></script>
    <script th:src="@{/layout/javascripts/algaworks.min.js}"></script>
    <script th:src="@{/javascripts/vendors/jquery.maskMoney.min.js}"></script>
    <script th:src="@{/javascripts/brewer.js}"></script>

    </body>
</html>

打包资源管理器

enter image description here

0 个答案:

没有答案