I'm trying to add autosubmit functionality to a exposed hierarchical taxonomy filter. I used the code on a standard filter before and it works fine
$(document).ready(function()
{
$("form#views-exposed-form-venues-page-1 #edit-submit-venues").hide();
$("form#views-exposed-form-venues-page-1 select#edit-area-hierarchical-select-selects-0").change(function() {
$("form#views-exposed-form-venues-page-1").submit();
});
});but I get this error
warning: Invalid argument supplied for foreach() in sites/all/modules/location/hierarchical_select/includes/theme.inc on line 372.
Does anyone have any suggestions on how to get this to work.
Comments
Comment #1
wim leersNo clue. What code is on that line?
Comment #2
marcus178 commentedAt that line it's
the full function that's part of is
Comment #3
wim leersSorry, I had misread it: I thought it was core's theme.inc. My bad!
Also, you shouldn't use jQuery's change event. Because the HTML you're binding to is being replaced and manipulated by JS, I'm not sure what it'll behave like.
You should use HS' own events. It's documented in API.txt.
Do something like:
That should work just fine :)
Comment #4
marcus178 commentedSorry I'm not very good with JS and can't work out what to do from the API
If tried
but the form is not submitted
Comment #5
wim leersI told you how you can do it. You repeat exactly what you said in the first post. That's not constructive.
I gave you the answer you needed, that took some of my time. Spend your time wisely and just learn the basic JS you need to know for this. I can't spoon-feed everything.
Comment #6
marcus178 commentedI haven't repeated what I put in may first post
My original code was
$("form#views-exposed-form-venues-page-1 select#edit-area-hierarchical-select-selects-0").change(function() {which I changed to your suggested
$('#hierarchical-select-29-wrapper').bind('change-hierarchical-select', function() {which I assume means when the dropdown with the id of 29 is changed it should go and process
$("form#views-exposed-form-venues-page-1").submit();However I have noticed something that could be causing this not to work. Every time I refresh the page the id is changing (incrementing by 1) which will mean the id in my code will never match and therefore not work. The id is now on 47 since I last posted. The exposed filter is in a block if that could have anything to do with it.
I can assure you that I am trying to work this out for myself, and have only posted because I have ran out of ideas.
Comment #7
robby.smith commentedfollowing
Comment #8
dinwal commentedFor the for each warning. Not sure if you are doing the same or not but sometimes the issue is too trivial and the solutions are too advanced to work. I kicked myself when I found the solution here:
http://amiatypist.blogspot.com/2010/04/invalid-argument-supplied-for-for...
Comment #10
dgastudio commented+1
Comment #11
rowanprice commentedhttp://drupal.org/project/views_hacks
"Views Filters Auto-submit
Auto-submit is initially off for all views. To turn it on, go to the Administer > Site configuration > Views Filters Auto-submit page (admin/settings/views_filters_autosubmit) and select the pages where auto-submit should be active, much like the blocks visibility settings.
Auto-submit supports Ajax-enabled views as well."
Comment #12
tobiberlinWhen I activate the module "Views Filters Auto-submit" it works fine with other exposed filters but not with those Hierarchical Select enabled. I get the error "Received an invalid response from the server". Any ideas what can cause this error?
Comment #13
booyeeka commentedi can not find this one...
i have installed view module, but on page admin/settings/views_filters_autosubmit i can not found Views Filters Auto-submit page.
can you help me with this?
Comment #14
Aambro commentedI have managed to "enable" autosubmit on exposed filters with HS on my website by putting this code into template.php file under:
function xxxx_preprocess_page(&$vars, $hook) {
$autosubmit_js = "
$(document).ready(function() {
$('form#views-exposed-form-Contacts-page-1')
.bind('change-hierarchical-select', function() {
$('form#views-exposed-form-Contacts-page-1').submit();
});
});
";
drupal_add_js($autosubmit_js, 'inline');
}
Comment #15
gaurishankarIt's working for me for a single HS !!!!!!!!!!
If you have more than one HS then it not working for second one or third one, Only work for first one HS.
I faced that problem, I have two HS exposed so it working for first one good but not for second one. So please have you any ideas for more than one exposed HS ??
ANY ONE HAVE IDEASSSSSSSSSSS.....
Thanks Aambro
Comment #16
Sel_Space commentedI used this code in a file , the form is submited but the values aren't present on the $form_sate
(function ($) {
Drupal.behaviors.exampleModule = {
attach: function (context, settings) {
$(".hierarchical-select-wrapper").bind("change-hierarchical-select",function(){
console.log("Yes changed hierarchical-select");
// jQuery("#location-selector-form").submit();
$("#location-selector-form .form-submit").trigger("click");
})
}
};
})(jQuery);
Comment #17
kars-t commentedDear fellow Drupal enthusiasts,
this issue is now lasting for a very long time in the issue queue and was unfortunately never solved. As Drupal is a open source project everyone is helping on voluntary basis. So that this is was not solved is nothing personal and means no harm. But perhaps no one had time to deal with this issue, maybe it is too complex or did not describe the problem comprehensibly.
But this issue is not the only one. There are thousands of issues on Drupal.org that have never been worked on or could not be processed. This means that we are building a wave that is unmanageable and just a problem for the Drupal project as a whole. Please help us keep the issue queue smaller and more manageable.
Please read again, "Making an issue report" and see if you can improve the issue. Test the problem with the current Core and modules. Maybe the problem doesn't exist anymore, is a duplicate or has even been solved within this issue but never closed.
Help can also be found for it on IRC and in the user groups.
In order to remove this issue, I have set this issue to "fixed"
If there is new information, please re-open the issue.
Comment #19
jenlampton@Aambro - The solution in #14 works great on my Drupal 6 site. Thanks!
@Kars-T, I'm pretty sure changing the status here to "Fixed" was the wrong thing to do. Fixed means that there is code - that has been committed to the module - that fixes this problem. It does not look like that is the case.
If you are not willing to fix the issue, then "closed (won't fix)" might be the choice you were looking for.
If you are still waiting for someone to provide a patch (and are open to fixing the problem), then this issue should still be "active' until someone provides that patch - even if it is a very, very long time ;)
Comment #20
kars-t commented@jenlampton
Hi Jen
please take a look here:
https://drupal.org/node/1989400
And at the module :)
This was an older version and I changed it.
I spoke to Wim and he agreed that we should close most D6 issues as we want to focus on D6. Still if the patch from #6 works should the issue be "needs review" or RTBC?
Comment #21
jenlamptonThere's no patch on this issue, so "needs review" and "RTBC" statuses don't apply :/
The solution I was referring to (in #14) was a bit of a hack - some custom jQuery I added into my theme as part of a preprocess function:
I understand that you are not willing to fix the old D6 bug - D6 usage is decreasing steadily. :) I'm re-categorizing as such. If someone else has this same problem in D7 (and it sounds like they shouldn't anymore) then they can locate the D7 issue where that bug was fixed, and gripe over there ;)
Thanks for your quick response @Kars-T! :)