2017-06-13 70 views
0

我試圖在Cakephp2的ctp文件中添加flex選擇,並得到以下錯誤。我將如何解決這個問題?我搜索了一下,並嘗試,但沒有解決方案,幫助。我很想聽到你的消息!由於錯誤,無法在cakephp2中實現一個庫(flexselect)

Uncaught TypeError: $(...).flexselect is not a function 
     at HTMLDocument.<anonymous> ((index):557) 
     at c (jquery-1.9.1.min.js:3) 
     at Object.fireWith [as resolveWith] (jquery-1.9.1.min.js:3) 
     at Function.ready (jquery-1.9.1.min.js:3) 
     at HTMLDocument.H (jquery-1.9.1.min.js:3) 

索引行557引用下面的代碼。

<script> 
    $(document).ready(function() { 
    $("select.special-flexselect").flexselect({ hideDropdownOnEmptyInput: true }); 
    $("select.flexselect").flexselect(); 
    }); 
</script> 
+0

您需要在您的頁面中包含具有'flexselect'插件的JS文件。如果您檢查插件的主頁,它甚至會顯示如何:http://rmm5t.github.io/jquery-flexselect/ –

回答

0

你必須包括所提供的JS-插件文件 'jQuery的的FlexSelect' 帶來的調用函數之前。

最佳做法是將「FlexSelect」文件加上自己的腳本文件,並放在身體標記的末尾,以減少加載時間。記住在包含插件之前也要包含JQuery,因爲它是一個依賴項。

[...] 
<body> 
    [...] 

    <script src="path/to/your/jquery.js"></script> 
    <script src="path/to/flex/flexselect.js"></script> 
    <script src="path/to/your/script.js"></script> 
[...] 
相關問題