Reputation: 585
following is my bootstrap radio button that i am trying to use in my JOOMLA extension.
<fieldset id="myEdit" class="radio btn-group">
<input type="radio" id="myEdit0" value="0">
<label for="myEdit0" class="btn active btn-danger">Yes</label>
<input type="radio" id="myEdit1" value="1">
<label for="myEdit1" class="btn">No</label>
</fieldset>
this button works fine when i click on YES but when i click back on NO it became totally unresponsive. other way around my radio button only works one time. . .but as i copied this html from JOOMLA global configuration window, its working fine there.
Anticipating helpful response
Upvotes: 0
Views: 2983
Reputation: 11
It´s difficult do find decent documentation on that, and a similar result that seems to be more bootstrap 3 compatible is here. This is working in joomla 3.5 front end.
<fieldset class="radio btn-group">
<label class="btn btn-default btn-danger" for="feedback0" >
<input type="radio" id="feedback0" value="0" name="feedback" checked="checked">No</label>
<label class="btn btn-default" for="feedback1">
<input type="radio" id="feedback1" value="1" name="feedback">Yes</label>
</fieldset>
Upvotes: 1
Reputation: 585
ok i found following piece of js code in template.js of JOOMLA administrator side. and by changing html as follow it worked
<fieldset id="myEdit" class="radio btn-group">
<input type="radio" id="myEdit0" value="1" name="myEdit">
<label for="myEdit0" class="btn">Yes</label>
<input type="radio" id="myEdit1" value="0" name="myEdit">
<label for="myEdit1" class="btn btn-danger">No</label>
</fieldset>
template.js
$(document).ready(function()
{
$('*[rel=tooltip]').tooltip()
// Turn radios into btn-group
$('.radio.btn-group label').addClass('btn');
$(".btn-group label:not(.active)").click(function()
{
var label = $(this);
var input = $('#' + label.attr('for'));
if (!input.prop('checked')) {
label.closest('.btn-group').find("label").removeClass('active btn-success btn-danger btn-primary');
if (input.val() == '') {
label.addClass('active btn-primary');
} else if (input.val() == 0) {
label.addClass('active btn-danger');
} else {
label.addClass('active btn-success');
}
input.prop('checked', true);
}
});
$(".btn-group input[checked=checked]").each(function()
{
if ($(this).val() == '') {
$("label[for=" + $(this).attr('id') + "]").addClass('active btn-primary');
} else if ($(this).val() == 0) {
$("label[for=" + $(this).attr('id') + "]").addClass('active btn-danger');
} else {
$("label[for=" + $(this).attr('id') + "]").addClass('active btn-success');
}
});
})
Upvotes: 1