2012-10-12 96 views
0

我是新來的telerik和MVC, 我想彈出一個模型窗體(它允許用戶訂閱) 在頁面加載telerik。 以下是Index.cshtml中的代碼,測試代碼「hello world」從未被調用過。頁面加載彈出窗體

@model Subscriber 
@{ Html.Telerik().Window() 
    .Name("Window") 
    .Title("Submit feedback") 
    .Content(@<text> 
     @using (Html.BeginForm("popupform", "window", FormMethod.Post, new { id = "feedback-form" })) 
     { 
      <p class="note">Subscribe<strong>not</strong> be saved.</p> 

      @Html.LabelFor(model => model.Email) 
      @Html.TextBoxFor(model => model.Email) 
      @Html.ValidationMessageFor(model => model.Email) 

      <div class="form-actions"> 
       <button type="submit" class="t-button t-state-default">Submit feedback!</button> 
      </div> 
     } 
     </text>) 
    .Width(400) 
    .Draggable(true) 
    .Modal(true) 
    .Visible(false) 
    .Render(); 
} 

@{ 
    ViewBag.Title = "Home Page"; 
} 
@{ 
Html.Telerik().ScriptRegistrar().OnDocumentReady(
@<text> 
    // put some javascript goodness in here 
    alert('hello world'); 
    $('#Window').data('tWindow').center().open(); 
</text>); 
} 

回答

0

試試這個:

.... 
@{ 
    Html.Telerik().ScriptRegistrar().OnDocumentReady(@"OnInit();"); 
} 
<script type="text/javascript"> 
function OnInit() { 
    // put some javascript goodness in here 
    alert('hello world'); 
    $('#Window').data('tWindow').center().open(); 
} 

我想,你的問題是標籤,但不能肯定。代碼必須在任何情況下工作。