I'm kinda of a begginer on JQuery and I'm writing my first plugin.
The plugin should handle form validation, in which I want to be able to
enable or disable validation.

The simplified version is like this:

(function($) {
  $.fn.checkForm = function(action) {

    function validateForm() {
          return false; // dont submit form, just that simple for this
example
    };

    return this.each( function() {
      if (action == "add")
            $(this).bind("submit", validateForm); // add validation for the
form

      if (action == "remove")
            // here I want to remove the validation from the form
            $(this).unbind("submit", validateForm); // This is NOT working
    });
  };
})(jQuery);

after calling $('#myForm').checkForm('add') it wont submit
but
after calling $('#myForm').checkForm('remove') it still wont submit

If I use $(this).unbind("submit"), it works, but removes all behavior
attached to the event, and there I only want to remove that given behavior.
Appreciate any help.
-- 
View this message in context: 
http://www.nabble.com/unbind-especific-function-not-working-tp16450021s27240p16450021.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.

Reply via email to