I like how the core content manager automatically selects the right option when you change the associated select box. CMF doesn't do this by default and I'm not sure why.
To fix this I add the following jquery code to my themes to get that functionality:
$('#cmf-filter-form select, #cmf-filter-form input').change(function(){
var id = $(this).attr('id');
if(id.substring(0,13) == 'edit-created-'){
if(id.substring(13,18) == 'after'){
id = 'edit-filter-created-after';
}else{
id = 'edit-filter-created-before';
}
}else{
id = id.replace('edit-','edit-filter-');
}
$('#'+id).click();
});
Would someone mind adding that code to the module so myself and others like me don't have to keep doing that over and over each time we make a new theme?
Otherwise, anyone interested in getting this working for their own sites can feel free to use that code. If you use a default theme like Garland for your site administration instead of your own theme, just put that in the page.tpl.php (surrounded by
$(function(){ *code here* });) or, if the theme has a scripts.js or some other similar file and you should be good to go.
Thanks.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | cmf.jquery.js_.txt | 518 bytes | jonathan1055 |
| #2 | _893256.cmf_.jquery_for_radio_auto_select-d6.patch | 498 bytes | jonathan1055 |
Comments
Comment #1
jonathan1055 commentedVery nice idea, thanks for the code, it works like a dream. For other folks who want to try it, here is a slight alternative to the two methods above.
Put the following code in a file named cmf.jquery.js and store it in the modules/cmf/ directory:
Then add the following line into cmf_filter_form(), somewhere near the top, eg just after the call to drupal_add_css.
This has the benefit that it will work for all themes on your site.
Thanks again for this,
Jonathan
Comment #2
jonathan1055 commentedAttached is the jquery file (with an extra extension of .txt to allow me to attach it) and a patch to do the addition of the line.
Thanks go to merzikain for providing the jquery. Let's hope we can get it included as this makes it much easier to use.
Jonathan
Comment #3
jonathan1055 commentedSetting status to 'needs review'
Comment #4
irakli commentedCommitted: http://drupalcode.org/project/cmf.git/commit/03af96e
Thank you!!!
Comment #5
jonathan1055 commentedThat's great thanks. Only yesterday I was thinking this queue was quiet and wondering if anything was happening.
I've taken the liberty of putting the status back to 'fixed' not closing it immediately, so that it remains in the queue on green for two weeks. Initially I didn't see it on my 'dashboard' and others may have missed it too.
Jonathan