Skip to content

Commit

Permalink
Add a function for initing boostrapSwitch outside of $()
Browse files Browse the repository at this point in the history
  • Loading branch information
bear454 committed Jun 26, 2018
1 parent dda6587 commit d703dad
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions app/assets/javascripts/osem-switch.js
@@ -1,7 +1,9 @@
$(function () {
$("[class='switch-checkbox']").bootstrapSwitch();
function checkboxSwitch(selector){
$(selector).bootstrapSwitch(

);

$('input[class="switch-checkbox"]').on('switchChange.bootstrapSwitch', function(event, state) {
$(selector).on('switchChange.bootstrapSwitch', function(event, state) {
var url = $(this).attr('url') + state;
var method = $(this).attr('method');

Expand All @@ -11,6 +13,10 @@ $(function () {
dataType: 'script'
});
});
}

$(function () {
checkboxSwitch("[class='switch-checkbox']");

$("[class='switch-checkbox-schedule']").bootstrapSwitch();

Expand Down

0 comments on commit d703dad

Please sign in to comment.