jsGears.com 技術論壇 - AJAX, JavaScript, jQuery, 網站開發, 前端效能優化's Archiver

wmh 發表於 2009-7-20 21:02

把 defer="defer" 刪掉應該就可以囉。因為在 IE 遇到 defer="defer"  會先繼續往下執行,當執行到那一行的時候,autocomplete 這個 function 都還未載入完成,所以會出現這個訊息。

niplover 發表於 2009-7-20 22:02

[quote]原帖由 [i]wmh[/i] 於 2009-7-20 21:02 發表 [url=http://jsgears.com/redirect.php?goto=findpost&pid=675&ptid=114][img]http://jsgears.com/images/common/back.gif[/img][/url]
把 defer="defer" 刪掉應該就可以囉。因為在 IE 遇到 defer="defer"  會先繼續往下執行,當執行到那一行的時候,autocomplete 這個 function 都還未載入完成,所以會出現這個訊息。 ... [/quote]

非常感謝wmh,確實是這個原因造成的!
我之所以加那個defer屬性,是由於之前ie無法打開該站點信息。。
再次感謝~

niplover 發表於 2009-7-20 22:09

還有個問題就是:

<input name="searchtext" type="text" class="input_search"
                                                        id="searchtext" maxlength="25" />
                                                <script language="javascript" type="text/javascript" charset=GBK>
                                                        $("#searchtext").autocomplete("get_tip_data.jsp");
                                                </script>

在get_tip_data.jsp中使用如下代碼
String searchtext = request.getParameter("searchtext");

获取的总是null,不知道爲什麽?

如果我使用 String searchtext = request.getParameter("q");
則獲取的是:searchtext ===  ???

注:我輸入的是中文

謝謝回覆!

[[i] 本帖最後由 niplover 於 2009-7-20 22:20 編輯 [/i]]

niplover 發表於 2009-7-20 23:17

[quote]原帖由 [i]niplover[/i] 於 2009-7-20 22:09 發表 [url=http://jsgears.com/redirect.php?goto=findpost&pid=677&ptid=114][img]http://jsgears.com/images/common/back.gif[/img][/url]
還有個問題就是:


                                               
                                                        $("#searchtext").autocomplete("get_tip_data.jsp");
                                               

在get_tip_data.jsp中使用如下代碼
String searchtext = request.getParameter("searchtext");

获取的总是null,不知道 ... [/quote]

解決了,用escape函數,谢谢wmh!

wmh 發表於 2009-7-20 23:17

server 端要用 q 這個變數去接才對喔,如果沒有接到正確的文字,可以先檢查看看網頁的編碼。

niplover 發表於 2009-7-22 10:24

wmh,我還有個問題就是:

當我輸入的時候,autocomplete是動態獲取到input中的值,該參數是q, 但能否動態獲取多個參數呢?  比如: 我input後面跟了一組單選框(book,author),我如何將選中的值(比如author)也能動態的傳入autocomplete呢? 聽說有個extraParams的東西,但不清楚何如使用?
望指教~ 謝謝!

wmh 發表於 2009-7-22 13:03

根據官網的說明, extraParams 的用法如下:
[code js]
$("#states").autocomplete(url, {
   extraParams: {
       country: function() { return $("#country").val(); }
   }
});
[/code]

如上,可以帶入額外的 country 參數,是抓目前 id="country" 這個欄位的值

niplover 發表於 2009-7-22 14:38

嗯,好的,謝謝wmh,等我晚上回家去試試~

niplover 發表於 2009-7-23 10:07

[quote]原帖由 [i]wmh[/i] 於 2009-7-22 13:03 發表 [url=http://jsgears.com/redirect.php?goto=findpost&pid=681&ptid=114][img]http://jsgears.com/images/common/back.gif[/img][/url]
根據官網的說明, extraParams 的用法如下:

$("#states").autocomplete(url, {
   extraParams: {
       country: function() { return $("#country").val(); }
   }
});


如上,可以帶入額外的 country 參數,是抓目前 ... [/quote]

嗯,可以的,謝謝wmh! 以後得學會自己先看官方doc,解決不了在問,嘿~

niplover 發表於 2009-7-26 14:56

wmh,再次請教~

如何才能讓autocomplete在使用方向鍵選中下拉列表中的某項時,input中同時也是這個值(像baidu一樣),而不是只能通過回車或單擊選中項使input為該值。。。

謝謝回覆!~

[[i] 本帖最後由 niplover 於 2009-7-26 14:57 編輯 [/i]]

wmh 發表於 2009-7-26 20:02

有個 autoFill 的屬性設定為 true 就可以囉

[url]http://docs.jquery.com/Plugins/Autocomplete/autocomplete#url_or_dataoptions[/url]
[quote]Fill the textinput while still selecting a value, replacing the value if more is typed or something else is selected.[/quote]

niplover 發表於 2009-7-27 09:28

非常感謝wmh~  晚上回去試試~

niplover 發表於 2009-7-28 09:29

[quote]原帖由 [i]wmh[/i] 於 2009-7-26 20:02 發表 [url=http://jsgears.com/redirect.php?goto=findpost&pid=694&ptid=114][img]http://jsgears.com/images/common/back.gif[/img][/url]
有個 autoFill 的屬性設定為 true 就可以囉

[url]http://docs.jquery.com/Plugins/Autocomplete/autocomplete#url_or_dataoptions[/url]
[/quote]

我昨天晚上回去試用了下,將autoFill的屬性設定為true,結果是這樣的:

龍[color=Red]龍[/color]
盤龍
狂龍
.
.
.

注:第一行為input,下麵是下拉列表,效果也就是如圖:   即:  input匹配第一行符合的記錄,自動去填充下拉列表第一行的在減去input字串長度的後一部份字符串(比如:input為龍, 下拉列表第一行為 盤龍, 盤龍長2,減去input的長1,還剩1,也就是說 需要在input后補齊的是盤龍的“龍”)。  不知道我這樣講清楚了沒?。。。

還有就是在下拉列表中用方向鍵選中項時,input不發生改變。。。

望指教~  非常感謝~!

wmh 發表於 2009-7-28 11:40

自動補齊的功能通常是要先符合前面輸入的字串,再補齊。
以你的資料為例,若有「盤龍」和「狂龍」兩筆資料,則輸入「盤」時,會自動補齊「龍」才是

niplover 發表於 2009-7-28 12:21

[quote]原帖由 [i]wmh[/i] 於 2009-7-28 11:40 發表 [url=http://jsgears.com/redirect.php?goto=findpost&pid=700&ptid=114][img]http://jsgears.com/images/common/back.gif[/img][/url]
自動補齊的功能通常是要先符合前面輸入的字串,再補齊。
以你的資料為例,若有「盤龍」和「狂龍」兩筆資料,則輸入「盤」時,會自動補齊「龍」才是 ... [/quote]
嗯,我明白你的意思。
如果是:

盤根錯節
盤龍

這樣的下拉列表的話, 輸入[盤]時,會補齊[盤根錯節],然後方向鍵下選中[盤龍],input依然是[盤根錯節]而不是預期的[盤龍]。。
這有什麽解決方案嗎?
謝謝!

wmh 發表於 2009-7-28 22:25

嗯,這個 plugin 原始的設計確實沒有在按「上」、「下」時重做 autoFill(),如果要這樣的呈現方式,可能要找其他 plugin 或自己修改囉。

niplover 發表於 2009-7-29 00:27

[quote]原帖由 [i]wmh[/i] 於 2009-7-28 22:25 發表 [url=http://jsgears.com/redirect.php?goto=findpost&pid=702&ptid=114][img]http://jsgears.com/images/common/back.gif[/img][/url]
嗯,這個 plugin 原始的設計確實沒有在按「上」、「下」時做 autoFill(),如果要這樣的呈現方式,可能要找其他 plugin 或自己修改囉。 [/quote]

嗯,好的,我再想想其他辦法。
謝謝wmh啦~~

niplover 發表於 2009-8-2 01:15

wmh,再請教一下~

今天又使用了一个jquery的datepicker插件  [url]http://jqueryui.com/demos/datepicker/[/url]
结果总是在FF里报下面这个错误:
错误: $("#fromtime").datepicker is not a function

PS;检查了js的顺序 和demo里是一致的。。(我那個autocomplete也正常,這樣應該可以排除是緩存的問題)。。
敢问这是啥原因呢?
代码如下:
js部分:
<script type="text/javascript" src="/xm/js/jquery-1.3.2.js"></script>
<script type="text/javascript" src="/xm/js/ui.core.js"></script>
<script type="text/javascript" src="/xm/js/ui.datepicker.js"></script>
<script type="text/javascript">
$(function() {
$('#fromtime').datepicker({
changeMonth: true,
changeYear: true
});
});
</script>

input部分:

<div>

<input name="fromtime" id="fromtime" type="text" size="30"
class="bg_sc_td_rt_lf" />

</div>

wmh 發表於 2009-8-3 00:00

$("#fromtime").datepicker is not a function 表示你的 js 檔可能沒有正確載入喔,請確認檔案位置都正確。不然可先試試看直接用 jquery 網站上面的版本:
[code html]
<script type="text/javascript" src="http://jqueryui.com/ui/ui.core.js"></script>
<script type="text/javascript" src="http://jqueryui.com/ui/ui.datepicker.js"></script>
[/code]

PS. 若有其他 plugin 使用的問題,建議你另開新帖發言喔,這樣才不會和 Autocomplete 的問題混在一起喔。

niplover 發表於 2009-8-3 09:07

[quote]原帖由 [i]wmh[/i] 於 2009-8-3 00:00 發表 [url=http://jsgears.com/redirect.php?goto=findpost&pid=711&ptid=114][img]http://jsgears.com/images/common/back.gif[/img][/url]
$("#fromtime").datepicker is not a function 表示你的 js 檔可能沒有正確載入喔,請確認檔案位置都正確。不然可先試試看直接用 jquery 網站上面的版本:





PS. 若有其他 plugin 使用的問題,建議你另開新帖發言喔,這樣 ... [/quote]

謝謝! 晚上回去試試~
PS:  OK,下次謹記不同主題發新帖~

頁: 1 2 3 [4] 5 6 7

Powered by Discuz! Archiver  © 2001-2009 Comsenz Inc.