2017-10-13 3 views
0

J'utilise un plugin css pur de iCheck-bootstrap v1.07 le long de celui-ci avec knockout v3.4.2. Lorsque vous utilisez iCheck sans knock-out, les cases à cocher rendent parfaitement. Cependant, quand j'ajoute KO et bootstrap, les deux ne semblent pas fonctionner ensemble. J'ai collé un extrait de mon code ci-dessous. S'il vous plaît aider avec ce que j'ai besoin de corriger?iCheck ne fonctionne pas avec knock-out

function model() { 
 
    var self = this; 
 
    selectOne = ko.observable(true); 
 
    selectTwo = ko.observable(false); 
 

 
} 
 

 
var mymodel = new model(); 
 

 
$(document).ready(function() { 
 
    ko.applyBindings(mymodel); 
 
});
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/> 
 

 
<link href="https://raw.githubusercontent.com/bantikyan/icheck-bootstrap/master/icheck-bootstrap.min.css" rel="stylesheet"/> 
 

 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> 
 
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> 
 
<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.2/knockout-min.js"></script> 
 

 

 

 

 
<div class="checkbox icheck-default"> 
 
    <input type="checkbox" data-bind="checked: selectOne" /> 
 
    <label>Select One with iCheck</label> 
 
</div> 
 
<div class="checkbox icheck-default"> 
 
    <input type="checkbox" data-bind="checked: selectTwo" /> 
 
    <label>Select One with iCheck</label> 
 
</div> 
 
<hr /> 
 
<div> 
 
    <input type="checkbox" data-bind="checked: selectOne" /> 
 
    <label>Select One w/o iCheck</label> 
 
</div> 
 
<div> 
 
    <input type="checkbox" data-bind="checked: selectTwo" /> 
 
    <label>Select Two w/o iCheck</label> 
 
</div>

Répondre

0

semble fonctionner très bien, peut-être votre cdn pour icheck ne fonctionne pas correctement. J'utilise https://cdn.rawgit.com/bantikyan/icheck-bootstrap/master/icheck-bootstrap.min.css

function model() { 
 
    var self = this; 
 
    selectOne = ko.observable(true); 
 
    selectTwo = ko.observable(false); 
 

 
} 
 

 
var mymodel = new model(); 
 

 
$(document).ready(function() { 
 
    ko.applyBindings(mymodel); 
 
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" /> 
 

 
<link href="https://cdn.rawgit.com/bantikyan/icheck-bootstrap/master/icheck-bootstrap.min.css" rel="stylesheet" /> 
 

 

 
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> 
 
<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.2/knockout-min.js"></script> 
 

 

 
<div class="checkbox icheck-default"> 
 
    <input type="checkbox" data-bind="checked: selectOne" /> 
 
    <label>Select One with iCheck</label> 
 
</div> 
 
<div class="checkbox icheck-default"> 
 
    <input type="checkbox" data-bind="checked: selectTwo" /> 
 
    <label>Select One with iCheck</label> 
 
</div> 
 
<hr /> 
 
<div> 
 
    <input type="checkbox" data-bind="checked: selectOne" /> 
 
    <label>Select One w/o iCheck</label> 
 
</div> 
 
<div> 
 
    <input type="checkbox" data-bind="checked: selectTwo" /> 
 
    <label>Select Two w/o iCheck</label> 
 
</div>

+0

partiellement travaillé comme le montre CSS. Cependant, j'ai remarqué que je ne peux pas cliquer sur la case avec iCheck. – usr4896260