I have an exposed views form, am geolocating in javascript and setting the co-ordinates in the exposed form.

This form submits properly when I click on the 'apply' button but does not when I use javascript to submit the form. The page refreshes, but the values have not been changed.

The form is standard FAPI. It is not a views-ajax form although I would like to move to ajax at some point in the future when I sort out the problems with gmaps + ajax.

Both of the following fail.


The full code is in github.

4 Answers 4


Add this code inside Drupal.behaviors.

$('.views-exposed-form APPLY_BUTTON ID/class').click(function() {
  // Submit the form

Hope it works.


The following would do the job:


You can submit form using jquery or add some trigger action

here is example code :

Drupal.behaviors.form_submit_processor = {
  attach: function (context, settings) {
    $("form#your-form").submit(function(e) {
     // some code here
  • Is there a way I can get this to fire when only a certain form is submitting. As this js runs for all form submissions true?
    – albo
    Commented Feb 26, 2017 at 11:54

Apologies, the problem was that the geocoding was being done asynchronously. Both of these submission methods work.

The solution is to trigger an event in the geocoding closure and react to this event.

I thought FAPI was somehow validating my submission.

geocoder.geocode({'address': address_string}, function (results, status) {

$(window).on('yhive_geocoded', function() {

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.