我正在使用一些使用microsoft ajax工具包編寫的控件。我想用jQuery在這些控件中觸發一個事件。我希望它應該像從jQuery觸發任何事件一樣簡單,但它似乎並沒有工作。下面是示例代碼..如何從jQuery調用Ajax控件事件
Ajax控件
/// <reference name="MicrosoftAjax.js"/>
Type.registerNamespace("MyNameSpace");
MyNameSpace.AjaxUserControl = function(element) {
MyNameSpace.AjaxUserControl.initializeBase(this, [element]);
}
MyNameSpace.AjaxUserControl.prototype = {
initialize: function() {
MyNameSpace.AjaxUserControl.callBaseMethod(this, 'initialize');
}
},
dispose: function() {
MyNameSpace.AjaxUserControl.callBaseMethod(this, 'dispose');
},
_onChange: function(evt) {
alert('On Change event.');
},
}
if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();
jQuery代碼:
var myJqueryControl = (function ($, AjaxControl) {
$(document).ready(function(){
var ajaxEventProxy = Function.createDelegate(AjaxControl, AjaxControl._onChange);
$("#JqueryCommandButton").click(ajaxEventProxy);
} (jQuery,MyNameSpace.AjaxUserControl));
它不工作,當按鈕被點擊我看不到裏面的onchange警報消息。將不勝感激關於如何使其工作的任何指導。
感謝 CSC
停止使用微軟的lame ajax庫和ajax控件工具包! :) – gillyb
我想..我不喜歡它,但必須支持舊代碼:( – CSC