Hello,
I posted about this in another feature thread, but this seems to be separate subject from that. This might be a great new feature for Views in future, but right now I'm in a kind of hurry and would appreciate a quick fix.
What I'm doing is an ajax view that updates itself without user hitting 'Apply' when selecting an option from exposed filters. It starts by working great with this code:
if ($.browser.msie) {
$('#edit-tid').change(function(){
$('#views-exposed-form').submit();
});
} else {
$('#edit-tid option').click(function(){
$('#views-exposed-form').submit();
return false;
});
}
But, after the first time the ajax form is submitted, it seems like event handlers stop working. Not even normal alert on 'onChange' works. I'm pretty stuck with this, and would really appreciate help! I'm not really sure if this is a Drupal bug or jquery or other bug, as this is a bit out of my field of expertise.
Comments
Comment #1
merlinofchaos commentedYou need to use Drupal's behaviors; AJAX replaces the HTML with new HTML and the drupal behavior system is what causes the new onchange attachment.
Do a search in the drupal docs for 'javascript behaviors'; I believe you'll find a couple of examples.
Comment #2
Sean-Khan commentedFound it & got it working, thanks for hint!
Comment #3
dgeilhufe@yahoo.com commentedThis would be a great feature for views, here is an outline of how it might fit into the IA. Comments?
User Goal:
Apply filters to lists of content with a single click.
Implementation Elements:
(1) New exposed filter option
Check box labeled: "Automatically apply selections".
The description would be "As a user makes filter selections, they are progressively applied without an apply button"
Behavior Note:
If any single exposed filter has this option checked, the behavior will apply to the view. This handles cases where one filter has the option checked and another does not. It introduces a UX problem since it will be difficult to debug why the behavior is happening if you have 10 exposed filters and only one of them has the option checked.
(2) User experience on the view
-- there is no apply button, clicking on any option automatically applies that option
-- as filters are applied, they are listed at the top of the view with an [x] (or other indicator). Clicking on the [x] reverses the selection.
-- there is a rest button which resets the view to its default state.
Considerations:
This makes a lot of sense for single selection dropdowns. Make the selection and see the results.
Still makes sense for multi selects if the application is progressive... choices A, B, C, D. First click A, A is applied. Then Click D, A+D are applied.
It even holds up with multiple filters. You select filter A, Option A and that is applied. Then you select Filter B, option C and then you have FilterA OptionA + FilterB OptionC.
Where does this not make sense?
Not being a coder, I can't do much more than help with design, usability, testing and such, but if anyone wants to put together some code for Merlin that does this, I am happy to provide moral support at the very least.
Comment #4
hefox commentedhttp://drupal.org/project/viewslivefilters Views live filters has some functionality I believe.
Comment #5
YK85 commented+1 subscribing
Can anyone please assist with the code to target specific filters to auto-apply the change but not all filters?
For example, I would like to Exposed Items per page to be auto-apply, but have the other filters require the Apply button to be press.
Thank you!
Comment #6
crea commentedSubs
Comment #7
MrVictor commentedSubscribing
Comment #8
merlinofchaos commentedhttp://drupal.org/node/306848