Uncaught TypeError: addtocart.off is not a function

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:


  1. if (typeof CustomfieldsForAll === "undefined") {
  2.     var CustomfieldsForAll = {
  3.            
  4.         handleForms : function(forms) {
  5.             forms.each(function() {
  6.                 var form = jQuery(this);
  7.                 var addtocart = form.find('.addtocart-button');
  8.                 addtocart.off('click');
  9.                 // addtocart.unbind();
  10.                 addtocart.click(function(e) {
  11.                     var form = jQuery(this).parents('form');
  12.                     var requiredChecked=CustomfieldsForAll.checkRequired(form);
  13.                     if(requiredChecked)Virtuemart.sendtocart(form);
  14.                     return false;
  15.                 });
  16.             });
  17.         },
  18.         checkRequired : function(form) {
  19.             var required_fields = form.find('.cf4all_required');
  20.             var emptyFound = false;
  21.             jQuery
  22.                     .each(
  23.                             required_fields,
  24.                             function() {
  25.                                 var field = jQuery(this);
  26.                                 var radios_checked = field
  27.                                         .find('.cf4all_radio:checked').length;
  28.                                 var checkboxes_checked = field
  29.                                         .find('.cf4all_checkbox:checked').length;
  30.                                 var select_selected = field
  31.                                         .find('select option:selected').length;
  32.                                 if (select_selected > 0)
  33.                                     var sel_value = field.find(
  34.                                             'select option:selected').attr(
  35.                                             'value');
  36.                                 if (radios_checked == 0
  37.                                         && checkboxes_checked == 0
  38.                                         && (select_selected == 0
  39.                                                 || typeof sel_value == 'undefined' || sel_value == 0)) {
  40.                                     emptyFound = true;
  41.                                     CustomfieldsForAll.displayMsg(field);
  42.                                 }
  43.                             });
  44.             if (emptyFound == false)return true;           
  45.             return false;
  46.         },
  47.        
  48.         eventHandler : function() {
  49.             jQuery('.cf4all_wrapper input').click(function() {
  50.                 var required = jQuery(this).parents('.cf4all_required');
  51.                 if (required)
  52.                     CustomfieldsForAll.hideMsg(required);
  53.             });
  54.             jQuery('.cf4all_wrapper select').change(function() {
  55.                 var required = jQuery(this).parents('.cf4all_required');
  56.                 if (required)
  57.                     CustomfieldsForAll.hideMsg(required);
  58.             });
  59.         },
  60.         displayMsg : function(el) {
  61.             el.find('span.cf4all_error_msg').css('display', 'inline-block');
  62.         },
  63.         hideMsg : function(el) {
  64.             el.find('span.cf4all_error_msg').css('display', 'none');
  65.         },
  66.         /**
  67.          * enable the built in tooltip effect
  68.          */
  69.         enableTooltips:function(){           
  70.            
  71.             jQuery(".cf4allTip").hover(
  72.                     function() {
  73.                           var label=jQuery(this).attr("data-tip");                         
  74.                           jQuery( this ).append( jQuery("<span class=\"cf4AllTip_inner\">"+label+"</span>" ) );
  75.                     },
  76.                     function() {
  77.                         jQuery( this ).find( "span:last" ).remove();
  78.                     });
  79.            
  80.         }
  81.     }
  82. }
  83. jQuery(document).ready(function($) {
  84.     /**
  85.      * Enable Tooltips
  86.      */
  87.     CustomfieldsForAll.enableTooltips();   
  88.    
  89.     /**
  90.      * Handle the required fields
  91.      */   
  92.     CustomfieldsForAll.eventHandler();   
  93.     var forms = jQuery("form.product");
  94.     setTimeout(function() {
  95.         CustomfieldsForAll.handleForms(forms);
  96.     }, 13);
  97. });