コントロールで jQuery プラグインを使用しようとしています。コントロールを配置できるページは、UpdatePanel を介して部分的なポストバックを使用します。次のように、コントロールの PreRender イベント中に jQuery とプラグインを含めます。
ScriptManager.RegisterClientScriptInclude(
this,
this.GetType(),
"jquery",
"/_infrastructure/javascript/jquery.js"));
ScriptManager.RegisterClientScriptInclude(
this,
this.GetType(),
"jquery.customPlugin",
"/_infrastructure/javascript/jquery.customPlugin.js");
customPlugin jQuery プラグインは、「executeCustomPlugin」と呼ばれる新しい関数をセットアップします。コントロールの PreRender イベントの後半で、コントロールの要素でプラグインを使用します。
ScriptManager.RegisterStartupScript(
this,
this.GetType(),
"customPlugin init script",
@"$(document).ready(function() {
$('#elementId').executeCustomPlugin();
});",
true);
ただし、実行すると、JavaScript エラーが発生します。
$('#elementId').executeCustomPlugin is not a function
jQuery プラグインがまったく実行されていないように見えますが、jQuery.customPlugin.js ファイルに window.alerts を設定したところ、実際に実行されています。
この問題を解決する方法はありますか?