Note that there are some explanatory texts on larger screens.

plurals
  1. POASP.NET MVC2 App Losing jquery ui button theme on Ajax call
    text
    copied!<p>I'm writing an ASP.NET MVC2 application that uses a jquery theme. I have a partial view that is updated with an Ajax call. When the partial view is re-rendered the buttons lose their jquery theme. I tried having the "onComplete" function restyle them, but no luck.</p> <p>JS function in master page:</p> <pre><code>function styleControls() { $("input:submit, button").button(); } </code></pre> <p>Partial View. The submit button styles correctly on load, but when a Ajax call updates the view it does not style.</p> <pre><code>&lt;%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl&lt;MVCBugTracker.ViewModels.ProjectPriorityViewModel&gt;" %&gt; &lt;div id="priorities"&gt; &lt;% if (Model.Priorities.Count &gt; 0) { %&gt; &lt;table id="priority-table"&gt; &lt;tr&gt; &lt;th&gt; &lt;/th&gt; &lt;th&gt; Priorities &lt;/th&gt; &lt;th&gt; Image &lt;/th&gt; &lt;/tr&gt; &lt;% foreach (var item in Model.Priorities) { %&gt;&lt;tr id="#row-&lt;%: item.PriorityID %&gt;"&gt; &lt;td&gt; &lt;%: Ajax.ActionLink("Delete", "DeletePriority", new { id = item.PriorityID }, new AjaxOptions { UpdateTargetId = "priorities", OnFailure = "handleFailure", OnComplete="styleControls", Confirm = "Are you sure you want to delete this Priority?" })%&gt; &lt;/td&gt; &lt;td&gt; &lt;%: item.Name%&gt; &lt;/td&gt; &lt;td style="text-align: center;"&gt; &lt;img src="&lt;%: ResolveUrl(item.ImageUrl) %&gt;" alt="" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;% } %&gt; &lt;/table&gt; &lt;% } %&gt; &lt;% using (Ajax.BeginForm("AddPriority", "Project", new { id = Model.ProjectID }, new AjaxOptions { UpdateTargetId = "priorities", OnFailure = "handleFailure", OnComplete = "styleControls" })) { %&gt; &lt;p&gt; &lt;label for="name"&gt; Priority Name:&lt;/label&gt; &lt;%: Html.TextBox("priorityname", "")%&gt;&lt;/p&gt; &lt;p&gt; &lt;% int count = 0; foreach (string s in Model.ImagesUrls) {%&gt; &lt;input type="radio" name="imageurl" value="&lt;%: s %&gt;" &lt;%= count == 0 ? "checked=\"checked\"" : "" %&gt; /&gt;&lt;img src="&lt;%: ResolveUrl(s) %&gt;" alt="" /&gt; &lt;% count++; } %&gt; &lt;/p&gt; &lt;p&gt; &lt;input type="submit" value="Submit" /&gt;&lt;/p&gt; &lt;% } %&gt; &lt;span id="priority-message" class="field-validation-error"&gt; &lt;% if (Model.Message != null) { %&gt; &lt;%: Model.Message%&gt; &lt;% } %&gt; &lt;/span&gt; &lt;/div&gt; </code></pre> <p>The partial view is inside a jquery tab.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload