>
> Just lazy I guess ;)
> In my example the are 6 groups with up to 12 checkboxes in every group.
> Often but not always a whole group or several groups have to be checked
> together. Would be nice to only have to click 6 times instead of 40 times :D
>
The thing is, this does involve a bit of coding and I'm a bit reluctant to
be doing and testing all that just for your special usecase. To begin with,
I would certainly construct the tag table using javascript, that way you
can easily add the desired toggle all inputs into the table head cells
programatically.
Anyway, here's some UNTESTED code for the script section that might point
you towards how it could be done. If you don't have any js knowledge, we'll
need to work on it further.
//make jQuery available via $
(function($){
//use a two-dimensional configuration array to define the tag categories
cats = [
[
'cat 1 title',
'cat 1 item 1 title|cat 1 item 1 tag',
'cat 1 item 2 title|cat 1 item 2 tag',
],[
'cat 2 title',
'cat 2 item 1 title|cat 2 item 1 tag',
'cat 2 item 2 title|cat 2 item 2 tag',
]
];
//first, determine the number of rows
var rows = 0;
cats.map(function(cat){
rows = Math.max(rows, cat.length);
})
var r, c, cat, $td, $tr,
$table = $('<table/>').addClass('borderless smallTable table100').
appendTo(place),
$tbody = $('<tbody/>').appendTo($table),
//the function that toggles all tags for a category
toggleAll = function(){
//get the checkbox to toggle all
var $i = $(this),
//and the containing table
$table = $i.closest('table');
//get all related tag inputs and set value to that of this
checkbox
$('[rel="' + $i.attr('toggle') + '"]', $table).val($i.val());
};
//loop the categories and append the tags to the table...
for(r = 0; r<rows; r++){
//add row
$tr = jQuery('<tr/>').appendTo($tbody);
//when header
if(r==0){
//add header class
$tr.addClass('table-header');
}
//loop cats
for(c==0;c< cats.length;c++){
//get category
cat = cats[c];
//when table head
if(r==0){
$td = jQuery('<td>')
.html(cat[0])
.appendto($tr);
jQuery('<input/>')
.text('all')
.attr('toggle','cat'+c)
.click(toggleAll)
.appendTo($td);
//table body
} else {
//get tag definition and split by pipe
var t = cat[r].split('|');
$td = jQuery('<td>').appendTo($tr);
jQuery('<input name ="tags[]" type="checkbox"/>')
.addClass('element checkbox')
.attr('rel','cat'+c)
.val(t[1])
.appendTo($td);
jQuery('<label/>')
.addClass('choice')
.attr('for','tags')
.text(val[0])
.appendTo($td);
}
}
};
})(jQuery);
They shouldn't. It's mostly as a precation against error. The form is
> geared toward old, not-so-computer-savy-old-ladies ;)
Well, then you need to sanitize any potentially corrupt values in your *
submitHandler*, e.g...
//get title input
var $title = jQuery('the selector for the title input');
//set value to trimmed value, removing any blanks
$title.val($.trim($title.val());
Tobias.
--
You received this message because you are subscribed to the Google Groups
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/groups/opt_out.