Drupal form ajax & Zurb Foundation3

A few months ago I embedded the Foundation3 Framework into Drupal as the base of a theme for an intra-net system.

At first I found some issues with loading both jquery.js and foundation.js, so I loaded the minimized foundation.js instead of jquery.js and all worked fine.

Last week i added a form to one of the modules that uses AJAX refresh, and here I bumped into a tough one, I received an error stating that handleError is not defined (actualy, it was: function [something] has no method handleError).

So as usual, I snooped around the Internet, and of course, jQuery deprecated handleError, so some suggested to add the function in the page before the triggering function is called, it only helped me see the error, not prevent it from being raised.

So I realized, that the reason the handleError is even called is because it depends on an old jQuery version, and with foundation I'm using a newer one.

In short, I added the latest jquery.form.js from malsup's website to the theme, and in template.php replaced misc/jquery.form.js with the new one, like this:

function THEMENAME_js_alter(&$js) {
  if (isset($js['misc/jquery.form.js'])) {
    $path = drupal_get_path('theme', 'THEMENAME') . '/js/jquery.form.js';
    
    $js[$path] = $js['misc/jquery.form.js'];
    $js[$path]['version'] = '3.27';
    $js[$path]['data'] = $path;
    
    unset($js['misc/jquery.form.js']);
  }
}

Enjoy