simsalabim / sisyphus

Gmail-like client-side drafts and bit more. Plugin developed to save html forms data to LocalStorage to restore them after browser crashes, tabs closings and other disasters.
http://sisyphus-js.herokuapp.com
MIT License
1.99k stars 221 forks source link

Not working with Bootstrap's checkbox type button group #126

Open sharmrk opened 9 years ago

sharmrk commented 9 years ago

I have used the button group elements in my form and they basically work like check boxes.

Here is the html code:

<div class="form-group col-md-3 col-sm-4 col-xs-8">
<label for="btn-group">Member Rank</label>
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-default btn-xs"> <input type="checkbox" value="1"> Silver
</label> <label class="btn btn-default btn-xs"> <input type="checkbox" value="2"> Gold
</label> <label class="btn btn-default btn-xs active"> <input type="checkbox" value="3"> Platinum
</label>
</div>
</div>

And I am using this to invoke sisyphus :

$( function() {
    $( "#myFormId" ).sisyphus(); 
} );

Am i doing something wrong?

simsalabim commented 9 years ago

@sharmrk form elements must have some identifying information in order to be persisted, such as id and/or name. Names should be enough. In your case it should be something like the following:

<input type="checkbox" value="1" name="group[]">
<input type="checkbox" value="2" name="group[]">

Please how "Checkbox Group" is implemented on demo site. Hope it helps.

sharmrk commented 9 years ago

@simsalabim : I added the name and id, but it was not working. Then i realised, the reason is because of the .btn-group and other .btn classes of bootsrap. So when i use the bootstrap button group to behave like a check-box group, sisyphus doesnt support that. If i remove the .btn-group and useit just like given in the demo (like regular checkboxes), it works fine.

I believe in my case, I have to store the .active class status for each checkbox in the localStorage and on refresh, i have to addclass(active) from the localstorage value. Any other thoughts?

simsalabim commented 9 years ago

That sounds weird because sisyphus and bootstrap should not interfere, unless bootstrap is blocking some events in any way. The demo site is using bootstrap too and there is no such an issue.

klemenskarssen commented 8 years ago

@sharmrk I have the same issue with the Bootstrap .btn-group inputs. Where you able to make a fix? I would be happy to see your solution.