bootstrap标签输入事件示例

时间:2015-05-13 15:53:10

标签: javascript jquery bootstrap-tags-input

我想像这段代码一样使用bootstrap tag input事件,但事件不会触发。

 $('#lastStep')
   .find('#input')
       // Revalidate the cities field when it is changed
       .change(function (e) {
           $('#lastStep').formValidation('revalidateField', 'cities');
       })

       .end()
   .formValidation({
       framework: 'bootstrap',
       excluded: ':disabled',

   })


    $("#input").on('itemRemoved', function (event) {
        alert(33)
    });

如何解决这个问题?

1 个答案:

答案 0 :(得分:-1)

没有表单验证,它可以完美地运行

<!DOCTYPE html>
<html>
<head lang="en">
  <meta charset="UTF-8">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
  <script src="bootstrap-tagsinput.js"></script>

  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.2.0/css/bootstrap.min.css">
  <link href="bootstrap-tagsinput.css" rel="stylesheet" type="text/css">

</head>
<body>

<script>
  $(document).ready(function () {
    $("#input").on('itemRemoved', function (event) {
      alert(33)
    });
  });
</script>

<div id="lastStep">
  <input type="text" id="input" data-role="tagsinput" value="Amsterdam,Washington,Sydney,Beijing,Cairo">
</div>

</body>
</html>