Reputation: 3392
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!
Upvotes: 1
Views: 50
Reputation: 7805
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>
Upvotes: 1