我毫不猶豫地回答這個問題,因爲我不是100%肯定,但我敢肯定,一個插件的兩個版本不能在同一個jQuery的實例,只要他們有共存同名(例如$.autocomplete
)。但是你可以解決這個問題。這裏有幾個例子,排序,我是多麼建議他們:
- 升級舊的自動完成功能實現,以使用1.8版本
- 只要使用舊版本的自動完成功能,爲您的新的實現
- 手動編輯名的新版本的插件的東西像autocomplete2。手動執行或者插件包含(見下文)
- 在同一頁面上使用兩個單獨的jQuery實例,將每個自動完成插件的版本加載到每個相應的jQuery實例中。加載每個jQuery版本並將它們存儲在單獨的變量中後,您可以通過調用
jQuery.noConflict
來完成此操作。 window.$
和window.$2
重命名版本的動態(塞繆爾Rossille的回答抓起,編輯不打破舊的自動完成功能實現)
<!-- First include the new autocomplete plugin (1.8) -->
<script type="text/javascript" src="path/to/autocomplete version 1.8"></script>
<script type="text/javascript">
// Then 'rename' the plugin to something else, e.g. autocomplete18
jQuery.fn.autocomplete18 = jQuery.fn.autocomplete;
</script>
<!-- Then include the old version, which will overwrite jQuery.autocomplete -->
<script type="text/javascript" src="path/to/autocomplete version 1.0"></script>
<script>
// $.autocomplete18 should now contain the new autocomplete version
// $.autocomplete should contain the old version, not breaking the previous
// implementation
</script>
你能不能有基於第二關1.0.2也? ? –
這樣做不是一個好主意。真的不應該花太多的精力來讓舊的自動完成工作與最新版本的jQuery UI(1.8.20 btw)一起工作。 –
這是其他幾個問題的重複。請不要提出重複的問題。 –