[Ovmsdev] Slider widget not disabled when first loading unchecked?
Michael Geddes
frog at bunyip.wheelycreek.net
Tue Dec 27 11:40:52 HKT 2022
Right, so that didn't work if the check-box was disabled (like in wifi)-
but this does seem to work!
var $sld = $(this).closest('.slider'), $cbi =
$sld.find('.slider-enable'), data = $.extend({ checked: ($cbi.prop("type")
=== "hidden" || $cbi.prop("checked")) }, $sld.data());
//.ichael
On Tue, 27 Dec 2022 at 11:04, Michael Geddes <frog at bunyip.wheelycreek.net>
wrote:
> Hi all,
> I've noticed that if you create a 'slider' widget with a checkbox that if
> it's unchecked when it first loads, then the slider is enabled. If you
> check/uncheck then the slider is disabled. Or at least that's what I seen
> in google chrome.
>
> I'm really not familiar with NodeJS, but this _seems_ to fix the problem:
>
> Does this fix make sense? If so - I'll do a p/r for it.
>
> //.ichael
>
>
> * Slider widget plugin
> */
>
> $.fn.slider = function(options) {
> return this.each(function() {
> - var $sld = $(this).closest('.slider'), data = $.extend({ checked:
> true }, $sld.data());
> + var $sld = $(this).closest('.slider'), $cbi =
> $sld.find('.slider-enable'), data = $.extend({ checked:
> $cbi.prop("checked") }, $sld.data());
> var opts = (typeof options == "object") ? options : data;
> // init?
> if ($sld.children().length == 0) {
> var id = $sld.attr('id');
> $sld.html('\
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openvehicles.com/pipermail/ovmsdev/attachments/20221227/e32388ed/attachment.htm>
More information about the OvmsDev
mailing list