我有一個Jquery自動完成ajax函數,其源是從後面的代碼計算出來的。不過,我使用客戶端腳本管理器獲取javascript的源代碼,但是我的函數沒有執行。調用jquery自動完成ajax函數
除此之外,我想調用該函數的AJAX代碼從後面通過
ClientScriptManager.RegisterStartupScript()
但同樣我的功能不執行。 我的功能是:
<form id="form1" runat="server">
<div>
<input id="Text1" type="text"/>
<input id="Text2" type="text" /><br />
<br />
<input id="Button2" type="button" value="button" />
<script type="text/javascript">
var mydataformat = [{ label: "....", value: "....", icon: "....." },
{ label: "....", value: ".....", icon: "....." }];
$(function() {
$("#Text1").autocomplete({
minLength: 0,
source: JSVar,
focus: function (event, ui)
{
$("#Text1").val(ui.item.label);
return false;
}})
.data("autocomplete")._renderItem = function (ul, item) {
return $("<li></li>")
.data("item.autocomplete", item)
.append("<a><img src='" + item.icon + "' width='32' height='32' /> " + item.label + "</a>")
.appendTo(ul);
};
});
</script>
你的函數在jquery的''''(function(){//是你的代碼嗎?});' – Marc 2012-02-24 04:56:51
是的。但不幸的是,我無法將從數據庫查詢計算出的數據添加到此jquery函數的源代碼中。 – vini 2012-02-24 05:08:31
如果你把'source:mydataformat'(當然有一些有效的值),當你在文本框中的列表中鍵入某些東西時它就起作用。 – 2012-02-24 17:01:27