2010-12-29 10 views
0

私のmvcアプリケーションのjqmodals内でjqueryウィジェットを使い始めました。当初jqModalとjqueryウィジェットヘルプウィジェットが起動しない

  1. は私が(「賞である」)アラートを取得するには、[追加]リンクをクリックすることができ、次のクリックは、所望の結果のためのモーダルを閉じるには、キャンセル。
  2. 編集リンクをクリックして、同じ結果を得ることができます。
  3. ただし、リンクを最初にクリックしてからリンクをクリックしてください。「忘れてしまった」という警告が表示されません。
  4. しかし、私はまだ戻って編集をクリックし、賞(警告メッセージ)を得ることができます。

AJAX: "/ホーム/ EditPrintAdLine" とAjax: "/ホーム/ AddPrintAdLine" 最終的にウィジェットをINITS要素が含まれている同じWebユーザーコントロールをレンダリングします(フィールド名はPrintAdLine_RunDateです)

アイデア?

<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %> 

<asp:Content ID="indexTitle" ContentPlaceHolderID="TitleContent" runat="server"> 
    Home Page 
</asp:Content> 

<asp:Content ID="indexContent" ContentPlaceHolderID="MainContent" runat="server"> 

    <div id="printAdLineEditDialog" class="jqmWindow"></div> 
    <div id="printAdDialog" class="jqmWindow"></div> 

    <table> 
    <tr><td><a id="printAdLineItem" href="#">Add a Line Item</a></td></tr> 
    <tr><td><a id="editPrintAdLine" href="#">Edit</a></td></tr>   
    </table> 

    <script type="text/javascript"> 
     $(document).ready(function() { 

      $.widget("ui.my_widget", { _init: function() { alert("My widget was instantiated"); } }); 

      // Add line  
      $('#printAdDialog').jqm({ 
       ajax: "/Home/AddPrintAdLine", 
       trigger: '#printAdLineItem', 
       onLoad: function(hash) {      
        $('#PrintAdLine_RunDate').my_widget(); 
       } 
      }); 

      // Edit line  
      $('#printAdLineEditDialog').jqm({ 
       ajax: "/Home/EditPrintAdLine", 
       trigger: '#editPrintAdLine', 
       onLoad: function(hash) { 
        $('#PrintAdLine_RunDate').my_widget(); 
       } 
      }); 
     }); 
    </script> 

</asp:Content> 

答えて

0

スコープの問題であることが判明しました。

$('#PrintAdLine_RunDate', 'printAdLineEditDialog').my_widget(); 

$('#PrintAdLine_RunDate', 'printAdDialog').my_widget(); 
関連する問題