From 651c65a025b6b3c5d2779411d8624b0873c39e34 Mon Sep 17 00:00:00 2001 From: jlukic Date: Thu, 26 Mar 2015 16:50:37 -0400 Subject: [PATCH] Move checkbox setup into method --- src/definitions/modules/checkbox.js | 30 +++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/definitions/modules/checkbox.js b/src/definitions/modules/checkbox.js index ca7581401..cdee42613 100644 --- a/src/definitions/modules/checkbox.js +++ b/src/definitions/modules/checkbox.js @@ -59,18 +59,7 @@ $.fn.checkbox = function(parameters) { module.create.label(); module.add.events(); - if( module.is.checked() ) { - module.set.checked(); - if(settings.fireOnInit) { - settings.onChecked.call($input.get()); - } - } - else { - module.remove.checked(); - if(settings.fireOnInit) { - settings.onUnchecked.call($input.get()); - } - } + module.setup(); module.observeChanges(); module.instantiate(); @@ -92,6 +81,23 @@ $.fn.checkbox = function(parameters) { ; }, + setup: function() { + if( module.is.checked() ) { + module.debug('Setting initial value to checked'); + module.set.checked(); + if(settings.fireOnInit) { + settings.onChecked.call($input.get()); + } + } + else { + module.debug('Setting initial value to unchecked'); + module.remove.checked(); + if(settings.fireOnInit) { + settings.onUnchecked.call($input.get()); + } + } + }, + refresh: function() { $label = $module.find(selector.label); $input = $module.find(selector.input);