Skip to content

Instantly share code, notes, and snippets.

@alejandroiglesias
Created November 2, 2012 16:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alejandroiglesias/4002292 to your computer and use it in GitHub Desktop.
Save alejandroiglesias/4002292 to your computer and use it in GitHub Desktop.
// Preview button
$(document).on('click', '#btn-preview', function (event) {
$.when(App._doFormAutosave()).done(function() {
// here I want the event to not be prevented
});
event.preventDefault();
});
@alejandroiglesias
Copy link
Author

// Preview button
$(document).on('click', '#btn-preview', function (event) {
  var self = this;
  $.when(App._doFormAutosave()).done(function() {
    self.dispatchEvent(event);
  });
  event.preventDefault();
});

@alejandroiglesias
Copy link
Author

// Preview button
$('#btn-preview').on('click', function (event) {
  var $btn = $(this);
  if ($btn.data('follow') === undefined) {
    $.when(App._doFormAutosave($formBrandEdit)).done(function(response) {
      $btn
        .data('follow', true)
        .attr('href', window.globalConfig.baseUrl + 'marca/' + response.brand.url)
        .attr('target', '_blank')
        .trigger(event);
    });
    event.preventDefault();
  }
  else {
    $btn.removeData('follow');
  }
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment