Hi
I have this piece of code. It works but the problem is the second instance of a function call is not working.
- On Dom ready, we call a function.
- When user submits a form, we open the squeezbox and then call this function to update a div.
here it fails. Help me fix this code.
window.addEvent('domready', function() {
var container = 'miniK2StoreCart';
if ($(container)) {
doMiniCart();
}
SqueezeBox.initialize({});
$$('.cart_form').each(function(el) {
el.addEvent('submit', function(e) {
new Event(e).stop();
var quantity = this.quantity.value;
// var url = this.action+'&quantity='+quantity+'&Itemid='+this.Itemid.value;
var url = this.action + '&quantity=' + quantity + '&Itemid=' + this.Itemid.value;
SqueezeBox.fromElement(el, {
url: url
});
//do the request only the minicart div is present
if ($(container)) {
doMiniCart();
}
});
});
function doMiniCart() {
var murl = 'index.php?option=com_k2store&view=mycart&format=ajaxmini';
var a = new Ajax(murl, {
method: "post",
onComplete: function(response) {
$(container).setHTML(response);
// (function() { document.body.removeChild($('tiendaModal')); }).delay(500);
}
}).request();
}
});