2

Ich muss etwas einfaches vermissen, aber ich kann es nicht sehen. Ich bin das Bootstrap tagsinput Plugin und ich versuche, hier einige Beispiele zu folgen: http://bootstrap-tagsinput.github.io/bootstrap-tagsinput/examples/

Hier ist mein Code:

<html> 
    <head> 
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"> 
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/bootstrap.tagsinput/0.4.2/bootstrap-tagsinput.css" /> 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> 
    <script src="https://cdn.jsdelivr.net/bootstrap.tagsinput/0.4.2/bootstrap-tagsinput.min.js"></script> 
    </head> 
    <body> 
    <input id="cities" class="form-control" value="New York,London" data-role="tagsinput" type="text"> 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> 
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> 
    <script> 
     $(function() { 
     $('#cities').tagsinput({ 
      maxTags: 3 
     }); 
     }); 
    </script> 
    </body> 
</html> 

ich folgende Javascript Störung erhalten:

tagsinput.html:15 Uncaught TypeError: $(...).tagsinput is not a function 

Ich habe versucht, data-role="tagsinput" wie in this SO answer vorgeschlagen, aber die Eingabe wird ein normales Textfeld und die Ausnahme tritt immer noch auf.

Was mache ich falsch?

+0

Haben Sie versucht, Ihre Skript-Tags neu zu ordnen, so dass jQuery und Bootstrap vor dem Tagsinput-Plugin kommen? – SimianAngel

Antwort

3

Sie laden 2 jquery min Dateien in Ihre script Tags.

entfernen Sie das eine nach bootstrap-tagsinput.min.js oder seit dem zweiten ist neuere Version laden, dass anstelle der ersten.

http://jsbin.com/xarasebibi/edit?html,output

+0

Ah, dummer Fehler. Vielen Dank! – aco

0

Sie dupliziert jquery Links. einer oben und der andere unten. und das bootstrap-tag-min-Skript muss erst verlinkt werden, nachdem Sie jquery link eingebunden haben. siehe unten für weitere Informationen. Hoffe das hilft

<html> 
    <head> 
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"> 
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/bootstrap.tagsinput/0.4.2/bootstrap-tagsinput.css" /> 
    </head> 
    <body> 
    <input id="cities" class="form-control" value="New York,London" data-role="tagsinput" type="text"> 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> 
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> 
    <script src="https://cdn.jsdelivr.net/bootstrap.tagsinput/0.4.2/bootstrap-tagsinput.min.js"></script> 
    <script> 
     $(function() { 
     $('#cities').tagsinput({ 
      maxTags: 3 
     }); 
     }); 
    </script> 
    </body> 
</html> 
+0

Das hat es geschafft, danke! – aco