Skip to content
Snippets Groups Projects
Commit 2f823c9c authored by Ariel Barreiro's avatar Ariel Barreiro
Browse files

Allow other modules to act on the created card element

parent 7760e35f
No related branches found
No related tags found
No related merge requests found
......@@ -59,6 +59,9 @@
// Create an instance of the card Element
var card = elements.create('card', options);
// Allow other modules to act on the created card element
$(element).trigger('drupalStripe.elementCreated', ['card', card, elements]);
// Add an instance of the card Element into the `card-element` <div>
card.mount('#' + element.id + '-card-element');
......
/**
* @file
* Provides stripe attachment logic.
*/
(function ($, window, Drupal, drupalSettings, Stripe) {
'use strict';
/**
* Attaches the stripe behavior
*
* @type {Drupal~behavior}
*
* @prop {Drupal~behaviorAttach} attach
*/
Drupal.behaviors.stripeExamples = {
attach: function (context, settings) {
$('.form-item-stripe').on('drupalStripe.elementCreate', function(event, type, options) {
console.log('Stripe ' + type + ' create options:', options);
});
$('.form-item-stripe').on('drupalStripe.elementCreated', function(event, type, element, elements) {
// Do something on card.
console.log('Stripe elements instance: ', elements);
console.log('Stripe ' + type + ' element intance:', element);
element.on('ready', function(e) {
// Add an event handler
});
});
}
};
})(jQuery, window, Drupal, drupalSettings, Stripe);
stripe_examples:
js:
js/stripe_examples.js: {}
css:
theme:
css/stripe_examples.css: {}
  • Chris Matthews @ChrisMatthews ·

    @hanoii Would it be possible to push this commit which allows other modules to act on the created card element to a 8.x-1.0-beta3 release? Thanks for considering!

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment