I found some bugs in my jQuery plugin I have published recently. So here is the bugfix release for the same.
You can download it here.
See Demo Radio with Checkbox Behavior Live in Action here.
Following bugs/issues are resolved.
Change Log:
- Compatibility will be with jQuery 1.2.3 or newer.
- jQuery chain will not break.
- Bug related to multiple radios is solved.
- Now using data() function from jQuery 1.2.3
- If radios are checked while page is getting loaded then it was required to click twice to uncheck.
- Tested on IE, Firefox, Safari.
Download Here
Trackback: Web 2.0 Announcer
#1 by Dragos on October 2, 2008 - 4:41 pm
Quote
Better try this as the above I think have some problems (anywai in FF I saw it, try use mouse/keyboard to see what I mean)
Here it is:
$.fn.extend({
triState:function(){
return this.each(function(){
$(this).data(‘status’, $(this).attr(‘checked’));
$(this).focus(function(){ $(this).data(‘status’, $(this).attr(‘checked’)); });
$(this).blur(function(){ $(this).data(‘status’, $(this).attr(‘checked’)); });
$(this).mousedown(function(){ $(this).data(‘status’, $(this).attr(‘checked’)); });
$(this).keydown(function(){ $(this).data(‘status’, $(this).attr(‘checked’)); });
$(this).click(function(){
if ($(this).data(‘status’))
$(this).attr(‘checked’, false);
$(this).data(‘status’, $(this).attr(‘checked’));
});
});
}
});
It’s working good on (tested) FF, IE(7 anyway, still may be a little problem there), Opera, Safari (for Win).
P.S. Use as (where “radioid” is the ID used by radio buttons…)
#2 by the666bbq on January 30, 2009 - 8:24 pm
Quote
Hi, thanks for this plugin,
I modified it somewhat so that could have multiple selected checkboxes behaving like a radio (once you check at least one, you cannot uncheck) so that you have all 4 circumstances “checked”
normal radio : zero or one, once selected, always one
normal checkboxes : zero or multiple
radioCheckboxGroup : the real zero or one
radioMultipleCheckboxGroup : zero or multiple, once selected at least one.
to do so I added radioMultipleCheckboxGroup as a copy of radioMultipleCheckboxGroup and changed the x.click to :
var boo = false;
for (var inti=0;inti<x.length;inti++)
{
if (x[inti].checked==true)boo=true;
}
if (!boo)
{
return false;
}
#3 by the666bbq on February 3, 2009 - 5:06 pm
Quote
for those using PHP, the filter on name might be to strict if you use array names (PHP uses them to combine some elements) and the PHP framework I am using (QCodo) has them on name too. Square brackets in name and/or id might not be W3C compliant but since PHP uses them I extended the name filter expression to :
var prefix = expression;
expression += “[@name=" + name + "]“;
expression += “, ” + prefix + “[@name^=" + name + "\[]“;
so basicly filter on elements with name attribute equal to the chosen name, and also apply to those elements starting with the chosen name[
now you have both name=LIST and name=LIST[ in your filtering results