Hi, I'm trying to add the Mobile Switch to a MVC 5 Web App but it is not rendering the switch widget, just a checkbox. Using the MVC Html wrapper, the HTML rendered is:
<
input
checked
=
"checked"
data-off-label
=
"No"
data-on-label
=
"Yes"
data-role
=
"switch"
id
=
"scoring-switch"
name
=
"scoring-switch"
type
=
"checkbox"
>
The css files that are included in my layout page are:
<
link
href
=
"@Url.Content("
~/Content/kendo/2015.1.429/kendo.common-bootstrap.min.css")"
rel
=
"stylesheet"
type
=
"text/css"
/>
<
link
href
=
"@Url.Content("
~/Content/kendo/2015.1.429/kendo.bootstrap.min.css")"
rel
=
"stylesheet"
type
=
"text/css"
/>
<
link
href
=
"@Url.Content("
~/Content/kendo/2015.1.429/kendo.dataviz.bootstrap.min.css")"
rel
=
"stylesheet"
type
=
"text/css"
/>
And the js files from my bundleconfig are:
bundles.Add(
new
ScriptBundle(
"~/bundles/kendo/2015.1.429/kendoscripts"
).Include(
"~/Scripts/kendo/2015.1.429/kendo.all.min.js"
,
"~/Scripts/kendo/2015.1.429/kendo.aspnetmvc.min.js"
));
Hello, I found a bug with the rendering if the switch. It renders off by exactly one pixel.
Please see the attached image. The top switch has the fix in place, the bottom one does not. You'll notice the underside shows one pixel column on the right.
The javascript was rendering the km-switch-handle class with an inline transformX, for 37px. It needs to be 38px to cover up the underside of the switch fully.
To fix this, I edited kendo.all.min.js. I replaced this line:
function(e){var t=this;t.position=e,t.handle.css(f,"translatex("+e+"px)"),t._animateBackground&&t.background.css(d,t.origin+e)}
with this line:
function(e){var t=this;t.position=e,t.handle.css(f,"translatex("+(e+1)+"px)"),t._animateBackground&&t.background.css(d,t.origin+e)}
However, while this fixed it when the switch was in the "on" state, it now has broken it by one pixel when the switch is in the "off" switch (see second attachment). Is there a permanent fix I can implement?
Thanks!!
-Chris
P.S. the only modifications I made to the default moonlight css is to change the on/off colors. Everything else is unchanged.
<
div
class
=
"view-content"
>
<
h1
>Welcome!</
h1
>
<
a
id
=
"skin-change"
data-role
=
"button"
data-click
=
"app.changeSkin"
>Flat</
a
>
<
p
>
Telerik AppBuilderâ„¢ enables you to build cross-platform device applications regardless of your
development platform by combining the convenience of a local development toolset with the
power and flexibility of the cloud.
</
p
>
<
input
data-role
=
"switch"
data-on-label
=
""
data-off-label
=
""
/>
<
div
class
=
"img"
></
div
>
</
div
>
<
input
data-role
=
"switch"
data-change
=
"switchChangedHandler"
data-subscriptionId
=
"10"
id
=
"switch1"
/>
<
input
data-role
=
"switch"
data-change
=
"switchChangedHandler"
data-subscriptionId
=
"9"
id
=
"switch2"
/>
<
input
data-role
=
"switch"
data-change
=
"switchChangedHandler"
data-subscriptionId
=
"8"
id
=
"switch3"
/>
function
switchChangedHandler(e) {
// I've seen this in a forum example but is it really the best way?
var
subscriptionId = e.sender.element.context.dataset.subscriptionId;
// How to best get it?
}