Note that there are some explanatory texts on larger screens.

plurals
  1. PORazor syntax causes jQuery Mobile form elements to lose styling
    primarykey
    data
    text
    <p>Having a bizarre issue that I'm hoping people can shed some like on. When I've been making forms with check boxes and radio buttons in my jQuery Mobile MVC 4 project, if I use Razor syntax to spit out the controls according to the view model e.g. @Html.RadioButtonFor etc instead of just writing the standard input type="radio", jQuery Mobile doesn't apply the styles to the elements. Screen shots and code differences included. Is this something to do with the way the controls are being rendered? Happens in both Views and Partial Views.</p> <p>I have changed just the first set of radio buttons here to demonstrate the point. If I change the whole form to Razor HTML helpers, I would get the same across all of the controls.</p> <p>Non-Razor: <img src="https://i.imgur.com/idYIL.png" alt="Non Razor"> Razor: <img src="https://i.imgur.com/FdYIc.png" alt="Razor"></p> <p>Non-Razor code:</p> <pre><code>&lt;fieldset data-role="controlgroup" data-type="vertical" class="recurrencyArea"&gt; &lt;legend&gt;&lt;/legend&gt; &lt;input type="radio" data-theme="b" name="Period" id="Daily" value="Daily" checked="checked" /&gt; &lt;label for="Daily"&gt;Daily&lt;/label&gt; &lt;input type="radio" data-theme="b" name="Period" id="Weekly" value="Weekly" /&gt; &lt;label for="Weekly"&gt;Weekly&lt;/label&gt; &lt;input type="radio" data-theme="b" name="Period" id="Monthly" value="Monthly" /&gt; &lt;label for="Monthly"&gt;Monthly&lt;/label&gt; &lt;/fieldset&gt; </code></pre> <p>Razor code:</p> <pre><code>&lt;fieldset data-role="controlgroup" data-type="vertical" class="recurrencyArea"&gt; &lt;legend&gt;&lt;/legend&gt; @Html.LabelFor(x=&gt;x.Period, "Daily") @Html.RadioButtonFor(x =&gt; x.Period, "Daily", new { data_theme = "b", @Checked = "checked", id = "Daily" }) @Html.LabelFor(x=&gt;x.Period, "Weekly") @Html.RadioButtonFor(x =&gt; x.Period, "Weekly", new { data_theme = "b", @Checked = "checked", id = "Weekly" }) @Html.LabelFor(x=&gt;x.Period, "Monthly") @Html.RadioButtonFor(x =&gt; x.Period, "Monthly", new { data_theme = "b", @Checked = "checked", id = "Monthly" }) &lt;/fieldset&gt; </code></pre> <p>Is the razor html being generated after the jquery mobile scripts have run over the page?</p> <p>Anybody with any helpful ideas/or indeed anyone who can spot any stupid mistakes would be a hero!</p> <p>Many thanks, Christian</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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