jquery - Issue with size drop down on Magento -
<script type="text/javascript"> //<![cdata[ var optionfileupload = { productform : $('product_addtocart_form'), formaction : '', formelements : {}, upload : function(element){ this.formelements = this.productform.select('input', 'select', 'textarea', 'button'); this.removerequire(element.readattribute('id').sub('option_', '')); template = '<iframe id="upload_target" name="upload_target" style="width:0; height:0; border:0;"><\/iframe>'; element.insert($('option_'+element.readattribute('id').sub('option_', '')+'_uploaded_file'), {after: template}); this.formaction = this.productform.action; var baseurl = '<?php echo $this->geturl('*/product/upload') ?>'; var urlext = 'option_id/'+element.readattribute('id').sub('option_', ''); this.productform.action = parsesidurl(baseurl, urlext); this.productform.target = 'upload_target'; this.productform.submit(); this.productform.target = ''; this.productform.action = this.formaction; }, removerequire : function(skipelementid){ for(var i=0; i<this.formelements.length; i++){ if (this.formelements[i].readattribute('id') != 'option_'+skipelementid+'_file' && this.formelements[i].type != 'button') { this.formelements[i].disabled='disabled'; } } }, addrequire : function(skipelementid){ for(var i=0; i<this.formelements.length; i++){ if (this.formelements[i].readattribute('name') != 'options_'+skipelementid+'_file' && this.formelements[i].type != 'button') { this.formelements[i].disabled=''; } } }, uploadcallback : function(data){ this.addrequire(data.optionid); $('upload_target').remove(); if (data.error) { } else { $('option_'+data.optionid+'_uploaded_file').value = data.filename; $('option_'+data.optionid+'_file').value = ''; $('option_'+data.optionid+'_file').hide(); $('option_'+data.optionid+'').hide(); template = '<div id="option_'+data.optionid+'_file_box"><a href="#"><img src="var/options/'+data.filename+'" alt=""><\/a><a href="#" onclick="optionfileupload.removefile('+data.optionid+')" title="remove file" \/>remove file<\/a>'; element.insert($('option_'+data.optionid+'_uploaded_file'), {after: template}); } }, removefile : function(optionid) { $('option_'+optionid+'_uploaded_file').value= ''; $('option_'+optionid+'_file').show(); $('option_'+optionid+'').show(); $('option_'+optionid+'_file_box').remove(); } } var optiontextcounter = { count : function(field,cntfield,maxlimit){ if (field.value.length > maxlimit){ field.value = field.value.substring(0, maxlimit); } else { cntfield.innerhtml = maxlimit - field.value.length; } } } product.options = class.create(); product.options.prototype = { initialize : function(config) { this.config = config; this.reloadprice(); document.observe("dom:loaded", this.reloadprice.bind(this)); }, reloadprice : function() { var config = this.config; var skipids = []; $$('body .product-custom-option').each(function(element){ var optionid = 0; element.name.sub(/[0-9]+/, function(match){ optionid = parseint(match[0], 10); }); if (config[optionid]) { var configoptions = config[optionid]; var curconfig = {price: 0}; if (element.type == 'checkbox' || element.type == 'radio') { if (element.checked) { if (typeof configoptions[element.getvalue()] != 'undefined') { curconfig = configoptions[element.getvalue()]; } } } else if(element.hasclassname('datetime-picker') && !skipids.include(optionid)) { dateselected = true; $$('.product-custom-option[id^="options_' + optionid + '"]').each(function(dt){ if (dt.getvalue() == '') { dateselected = false; } }); if (dateselected) { curconfig = configoptions; skipids[optionid] = optionid; } } else if(element.type == 'select-one' || element.type == 'select-multiple') { if ('options' in element) { $a(element.options).each(function(selectoption){ if ('selected' in selectoption && selectoption.selected) { if (typeof(configoptions[selectoption.value]) != 'undefined') { curconfig = configoptions[selectoption.value]; } } }); } } else { if (element.getvalue().strip() != '') { curconfig = configoptions; } } if(element.type == 'select-multiple' && ('options' in element)) { $a(element.options).each(function(selectoption) { if (('selected' in selectoption) && typeof(configoptions[selectoption.value]) != 'undefined') { if (selectoption.selected) { curconfig = configoptions[selectoption.value]; } else { curconfig = {price: 0}; } optionsprice.addcustomprices(optionid + '-' + selectoption.value, curconfig); optionsprice.reload(); } }); } else { optionsprice.addcustomprices(element.id || optionid, curconfig); optionsprice.reload(); } } }); } } function validateoptionscallback(elmid, result) { var container = $(elmid).up('ul.options-list'); if (result == 'failed') { container.removeclassname('validation-passed'); container.addclassname('validation-failed'); } else { container.removeclassname('validation-failed'); container.addclassname('validation-passed'); } } var opconfig = new product.options(<?php echo $this->getjsonconfig() ?>); //]]> </script>
before merge js , above code working. after merge, here 3 main problems js errors showing in firebug:
- referenceerror: $ not defined
- typeerror: property 'handleevent' not callable.
- typeerror: opconfig undefined
and due this, size drop down box not changing price size change value in drop down.
how resolve this?
Comments
Post a Comment