Uncaught TypeError: addtocart.off is not a function
I'm using a plugin that Chrome has caught, but I'm not sure how to fix it. I'm receiving an error: Uncaught TypeError: addtocart.off is not a function. The plugin I'm using is integrated with Joomla.
I'm not sure if it's a cause of the plugin or the jQuery version I'm running: 1.6.1
I appreciate the second set of eyes.
The code is below:
- if (typeof CustomfieldsForAll === "undefined") {
- var CustomfieldsForAll = {
-
- handleForms : function(forms) {
- forms.each(function() {
- var form = jQuery(this);
- var addtocart = form.find('.addtocart-button');
- addtocart.off('click');
- // addtocart.unbind();
- addtocart.click(function(e) {
- var form = jQuery(this).parents('form');
- var requiredChecked=CustomfieldsForAll.checkRequired(form);
- if(requiredChecked)Virtuemart.sendtocart(form);
- return false;
- });
- });
- },
- checkRequired : function(form) {
- var required_fields = form.find('.cf4all_required');
- var emptyFound = false;
- jQuery
- .each(
- required_fields,
- function() {
- var field = jQuery(this);
- var radios_checked = field
- .find('.cf4all_radio:checked').length;
- var checkboxes_checked = field
- .find('.cf4all_checkbox:checked').length;
- var select_selected = field
- .find('select option:selected').length;
- if (select_selected > 0)
- var sel_value = field.find(
- 'select option:selected').attr(
- 'value');
- if (radios_checked == 0
- && checkboxes_checked == 0
- && (select_selected == 0
- || typeof sel_value == 'undefined' || sel_value == 0)) {
- emptyFound = true;
- CustomfieldsForAll.displayMsg(field);
- }
- });
- if (emptyFound == false)return true;
- return false;
- },
-
- eventHandler : function() {
- jQuery('.cf4all_wrapper input').click(function() {
- var required = jQuery(this).parents('.cf4all_required');
- if (required)
- CustomfieldsForAll.hideMsg(required);
- });
- jQuery('.cf4all_wrapper select').change(function() {
- var required = jQuery(this).parents('.cf4all_required');
- if (required)
- CustomfieldsForAll.hideMsg(required);
- });
- },
- displayMsg : function(el) {
- el.find('span.cf4all_error_msg').css('display', 'inline-block');
- },
- hideMsg : function(el) {
- el.find('span.cf4all_error_msg').css('display', 'none');
- },
- /**
- * enable the built in tooltip effect
- */
- enableTooltips:function(){
-
- jQuery(".cf4allTip").hover(
- function() {
- var label=jQuery(this).attr("data-tip");
- jQuery( this ).append( jQuery("<span class=\"cf4AllTip_inner\">"+label+"</span>" ) );
- },
- function() {
- jQuery( this ).find( "span:last" ).remove();
- });
-
- }
- }
- }
- jQuery(document).ready(function($) {
- /**
- * Enable Tooltips
- */
- CustomfieldsForAll.enableTooltips();
-
- /**
- * Handle the required fields
- */
- CustomfieldsForAll.eventHandler();
- var forms = jQuery("form.product");
- setTimeout(function() {
- CustomfieldsForAll.handleForms(forms);
- }, 13);
- });