Mario Moura escribió:
Hi SeVir and Jörn,
Yes I was thinking about this tonight. I need avoid the click event.
$("#attach-button").each(function(){
$(this).bind("click", function(){
$("#node-form")[0].submit();
return false;
});
});
First, you don't need iterate with each method if you have only an
element $("#attach-buttom") is only
one DOM element, also, bind attach the event handler to all elements
returned by the jQuery selector $().
So, the code is only:
$("#attach-buttom").bind("click",function(){
$("#node-form")[0].submit();
return false;
});
I tested your function but I can only click attach-button one time.
The second click dont work.(I cant attach more files) I made a lot of
variations.
The element must attach always the click event handler, if only works on
the first click I suggest that
you are updating the form by AJAX calls maybe ??
If you refresh or insert a new "#attach-butom" (removing the old, you
can only one unique ID element),
you need attach again the event handler or using *livequery* plugin:
http://brandonaaron.net/docs/livequery/
$("#attach-buttom").livequery("click", function(){
//Submitting by AJAX
var the_form = $("#node-form");
$("#node-form").load(the_form[0].action, {parameters: ...});
//$("#node-form")[0].submit(); //no normal submit
return false;
});
Although you update the form, livequery update the event handler.
I was thinking insert another function to unbind the event or
something like this.
So I tried but dont work
$("#attach-button").each(function(){
$(this).bind("click", function(){
$("#node-form")[0].submit(
function() {
$("#attach-button").unbind();
}
);
return false;
});
});
Ideas?
Regards
Mario
2007/8/23, SeViR <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>:
Mario Moura escribió:
> Hi SeVir and Folks
>
>
> My form have a ajax button. Ajax button always is type="submit" so I
> tested ValidationAide and Jquery Validation ( bassistance.de
<http://bassistance.de>
> <http://bassistance.de>)
>
> Both plugins have the following bad behavior.
>
> When I click in Ajax Button (value="Attach" id="attach-button"
> name="attach") both think that I am trying send the form and try
validate.
>
> So My Ajax function cant work :(
>
> Can I bypass this? How can I hack this? Ideas?
>
> How can I say to "Jquery Validation" to validate
id="edit-submit" and
> not type="submit"? Or how can exclude id="attach-button" from
Validation?
>
> Because $("#myform").validate(); already declared.
>
> My Form is:
>
>
> <form enctype="multipart/form-data" id="myform" method="post"
> action="/send/invoice">
>
> <input type="submit" class="form-submit" value="Attach"
> id="attach-button" name="attach"/>
>
> <input type="submit" class="form-submit" value="Submit"
> id="edit-submit" name="op"/>
>
> </form>
>
> Regards
>
> Mario
Using any validation library, in your HTML example you can bypass the
validation using this code:
//inside document.ready
$("#attach-button").click(function(){
$("#myform")[0].submit(); //DOM submit trigger, not jQuery
submit
trigger
return false;
});
--
Best Regards,
José Francisco Rives Lirola <sevir1ATgmail.com>
SeViR CW · Computer Design
http://www.sevir.org
Murcia - Spain