1

I have 1-st script:

<script>
   App.validate(helper, form, "", // Simple request to the server
      function(data) {
         if (data.products_in_cart) {
           ... I dont't know how to trigger event (cart update for example)  
         }
      },'POST'
   );
</script>

And 2-nd (as a plugin):

<script>
   var handler = document.id('html');
   handler.addEvent('event from the script above - cart update', function(data){
     handler.set('html', JSON.stringify(data));
   });
</script>

Is this possible to create? My javascript framework is Mootools. Thanks!

1 Answer 1

1

Try:

<script>
   App.validate(helper, form, "", // Simple request to the server
      function(data) {
         if (data.products_in_cart) {
           window.fireEvent('validateEvent', {cart:data});
         }
      },'POST'
   );
</script>

and the other file:

<script>
   var handler = document.id('html');
   handler.addEvent('validateEvent', function(data){
     handler.set('html', JSON.stringify(data));
   });
</script>
1
  • Should be: window.fireEvent('validateEvent', {cart:data});
    – XTRUST.ORG
    Commented Feb 11, 2014 at 8:41

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