Question

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!

Was it helpful?

Solution

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>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top