Bootstrap tag input : undefined is not a function error.

0 Mark Tan · October 16, 2014
I faced a problem when try to set some rules to the tag input.




But if i remove the rules, then everything works well. Thanks.
  tag.tagsinput({
        maxTags: 3
    });


Error message
Error message : Uncaught TypeError: undefined is not a function 
bootstrap-tagsinput.min.js:5b.removeAll
bootstrap-tagsinput.min.js:5(anonymous function)
bootstrap-tagsinput.min.js:5m.extend.each jquery.min.js:2m.fn.m.each jquery.min.js:2a.fn.tagsinput
bootstrap-tagsinput.min.js:5(anonymous function) main.js:128m.event.dispatch jquery.min.js:3r.handle jquery.min.js:3


Full code

var tag = $('#tag');

tag.tagsinput({
        maxTags: 3
    });

    $("#categories").change(function() {
        var value = $(this).val();
        tag.tagsinput('removeAll');
        var id;
        switch(value) {
            case 'female':
                id = 2;
                break;
            case 'male':
                id = 1;
                break;
            case 'equipment':
                id = 3;
                break;
        }
        $('#loading').fadeIn("fast");
        $.ajax({
            url: ROOT+"product/get_parts/"+id,
            dataType: 'json'
        }).done(function (result) {
            $.each(result, function(index, value) {
                tag.tagsinput('add', value.name);
            });
            $('#loading').fadeOut("fast");
        });
        
        
    });

Post a Reply

Replies

Oldest  Newest  Rating
0 Mark Tan · October 16, 2014
Hi, i found that there is the bug exist in this plugin 

https://github.com/TimSchlechter/bootstrap-tagsinput/issues/241

if use the maxTags option together when the removeall, the error will be occur. 
0 Mark Tan · October 16, 2014
Thanks for the reply. Actually i refering to a website http://timschlechter.github.io/bootstrap-tagsinput/examples/
It does mentioned about the exist of the maxTags and others. Is that different version ? :)
  • 1

Javascript

107,113 followers
About

A scripting language that is added to standard HTML to create interactive effects, apps, games for the browser.

Links
Moderators