Closed GoogleCodeExporter closed 8 years ago
A simple workaround for this is to destroy the ddcl, edit it, then create it
again.
$("#sampleButton").click(function() {
var arr = [1,5];
$("#sampleSelect").dropdownchecklist("destroy");
$("#sampleSelect").val(arr);
$("#sampleSelect").dropdownchecklist({ emptyText: "no selection", width: 125, icon: {} });
});
Original comment by Bry...@gmail.com
on 8 Mar 2011 at 9:01
Thanks for your comment! Sadly, in my "real world" app I do a lot more after
initializing (mouseovers and such) and thus I had to recreate all action
listeners again, so I thought a refresh would be nice.
I'm going to have a look at it, maybe I find the time to fix it.
Original comment by sysi...@gmail.com
on 8 Mar 2011 at 9:44
Ok, I think I fixed this issue, but I couldn't check all side effects though.
It would be really nice if anyone else could have a look at this, and maybe
merge this piece of code into the repository (I don't know what's the right
way, should I suggest a patch or what?)
refresh: function () {
var self = this, sourceSelect = this.sourceSelect, dropWrapper = this.dropWrapper;
var allCheckBoxes = dropWrapper.find("input");
var allGroups = dropWrapper.find(".ui-dropdownchecklist-group");
var groupCount = 0;
var optionCount = 0;
sourceSelect.children().each(function (index) {
var opt = $(this);
var disabled = opt.attr("disabled");
if (opt.is("option")) {
var selected = opt.attr("selected");
var anItem = $(allCheckBoxes[optionCount]);
self._refreshOption(anItem, disabled, selected);
optionCount++;
} else if (opt.is("optgroup")) {
var text = opt.attr("label");
if (text != "") {
var aGroup = $(allGroups[groupCount]);
self._refreshGroup(aGroup, disabled);
groupCount++;
}
opt.children("option").each(function () {
var subopt = $(this);
var subdisabled = (disabled || subopt.attr("disabled"));
var selected = subopt.attr("selected");
var subItem = $(allCheckBoxes[optionCount]);
optionCount++;
self._refreshOption(subItem, subdisabled, selected);
});
}
});
// update the text shown in the control
self._updateControlText();
}
Original comment by sysi...@gmail.com
on 8 Mar 2011 at 10:43
As you have found, multiple groups threw the option count off and messed up the
selector refresh.
I have incorporated your fix into the base code, and adjusted the test page to
include multiple groups.
When I move 1.2 out of QA and into production, your fix will be part of the
release.
Thank you for your contribution.
Original comment by womohun...@ittrium.com
on 9 Mar 2011 at 1:55
You're welcome! I think this is a great plugin, and the bug crossed my way, so
I had to track it down ;-)
Original comment by sysi...@gmail.com
on 9 Mar 2011 at 7:40
Fixed in 1.3 (really, 1.2qa)
Original comment by womohun...@ittrium.com
on 13 Apr 2011 at 4:49
Original issue reported on code.google.com by
sysi...@gmail.com
on 8 Mar 2011 at 8:23