- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2022 12:12 PM
Hi Everyone,
I am using a slider toggle for a custom widget in Service Portal. I came across an issue wherein if I clicked on multiple sliders, the sliders turns to a checkbox. Anyone have any idea what's wrong? Here is my code:
HTML:
<label ng-click="c.subscribe()">
<input class="subs-switch" type="checkbox" data-toggle="toggle" data-on=" " data-off=" " data-size="mini" data-style="ios">
${Subscribe to all}
</label>
Client Script:
c.subscribe = function(){
c.data.action = "subscribe";
c.server.update().then(function(){
c.data.action = undefined;
});
}
CSS:
.subs-switch{
width: 34px;
height: 20px;
}
.toggle.ios, .toggle-on.ios, .toggle-off.ios {
border-radius: 20px;
}
.toggle.ios .toggle-handle {
border-radius: 20px;
}
.toggle-on {
background-color: #4696EC;
}
Here is a screenshot of the issue:
Regards,
Diane
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2022 01:13 PM
Hello
I was not able to guess the issue in your code it looks fine but not sure what happened but may be its CSS problem but I tried with some different code and it worked please try it and let me know
Print them in loop ng-repeat may be you might have used to render multiple radio buttons same way do it for my below code
HTML:
<label class="switch" ng-click="c.subscribe()">
<input type="checkbox" checked>
<span class="slider round"></span>
</label>
<p>
<p>${Subscribe to all}</p>
client controller:
api.controller=function() {
/* widget controller */
var c = this;
c.subscribe = function(){
alert('test');
c.data.action = "subscribe";
c.server.update().then(function(){
c.data.action = undefined;
});
};
};
CSS:
.switch {
position: relative;
display: inline-block;
width: 60px;
height: 34px;
}
.switch input {
opacity: 0;
width: 0;
height: 0;
}
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
-webkit-transition: .4s;
transition: .4s;
}
.slider:before {
position: absolute;
content: "";
height: 26px;
width: 26px;
left: 4px;
bottom: 4px;
background-color: white;
-webkit-transition: .4s;
transition: .4s;
}
input:checked + .slider {
background-color: #2196F3;
}
input:focus + .slider {
box-shadow: 0 0 1px #2196F3;
}
input:checked + .slider:before {
-webkit-transform: translateX(26px);
-ms-transform: translateX(26px);
transform: translateX(26px);
}
/* Rounded sliders */
.slider.round {
border-radius: 34px;
}
.slider.round:before {
border-radius: 50%;
}
Please mark my answer correct if it is helpful to you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2022 01:13 PM
Hello
I was not able to guess the issue in your code it looks fine but not sure what happened but may be its CSS problem but I tried with some different code and it worked please try it and let me know
Print them in loop ng-repeat may be you might have used to render multiple radio buttons same way do it for my below code
HTML:
<label class="switch" ng-click="c.subscribe()">
<input type="checkbox" checked>
<span class="slider round"></span>
</label>
<p>
<p>${Subscribe to all}</p>
client controller:
api.controller=function() {
/* widget controller */
var c = this;
c.subscribe = function(){
alert('test');
c.data.action = "subscribe";
c.server.update().then(function(){
c.data.action = undefined;
});
};
};
CSS:
.switch {
position: relative;
display: inline-block;
width: 60px;
height: 34px;
}
.switch input {
opacity: 0;
width: 0;
height: 0;
}
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
-webkit-transition: .4s;
transition: .4s;
}
.slider:before {
position: absolute;
content: "";
height: 26px;
width: 26px;
left: 4px;
bottom: 4px;
background-color: white;
-webkit-transition: .4s;
transition: .4s;
}
input:checked + .slider {
background-color: #2196F3;
}
input:focus + .slider {
box-shadow: 0 0 1px #2196F3;
}
input:checked + .slider:before {
-webkit-transform: translateX(26px);
-ms-transform: translateX(26px);
transform: translateX(26px);
}
/* Rounded sliders */
.slider.round {
border-radius: 34px;
}
.slider.round:before {
border-radius: 50%;
}
Please mark my answer correct if it is helpful to you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2022 12:17 AM
Thank you, Mohith. The issue is with my css. This is now working as expected. I appreciate your help on this!
Regards,
Diane