0

can this code affect other submit buttons which are not in the with the id="form_data_voting" ? I assume not, right? And the 3rd line does just affect the code of the with the id #form_data_voting as well, right?

jQuery('body').on('submit', '#form_data_voting', function() {

var formContents = jQuery(this).serializeArray();           
var formSource = jQuery(this).find('input[type="submit"]').attr("alt");

I'm facing problems with two plugins in wordpress which are both activated and the submit button of the other plugin does not work correctly...

Thanks!

1
  • Thanks. I figured it out... the reason was my JQuery 1.9.1 which i included with this code: //INCLUDES add_action('wp_enqueue_scripts', function() { $myStyleFile = plugins_url( 'js/jquery-1.9.1.min.js', FILE ) ; wp_enqueue_script( 'jquery_script',$myStyleFile,false,'1.0'); }); But how can i check whether JQuery has already been included through other plugins...? Commented Mar 12, 2013 at 17:32

3 Answers 3

1

It's actually an event handler for the form being submitted, as opposed to the button being clicked, so it will handle programmatic submits as well as people pressing enter on inputs that trigger submit.

And yes, the third line of code will only find the submit element(s) within the form specified.

Sign up to request clarification or add additional context in comments.

Comments

0

You could force the submit, but it's kinda strange.

$('.your-other-submit').on('click', function(e) {
    e.preventDefault();
    $('#form_data_voting').submit();
});

It will run your previous code.

You might even get some more external forms within the submit :

var otherFormContents = jQuery('#yourOtherForm').serializeArray();  

I agree with @Archer btw.

Comments

0

Yes, this applies only on the id=#form_data_voting. (including the third line)

In the mean time, this is not complete code, the { has to be closed.

if it was like this

jQuery('body').on('submit', '#form_data_voting', function() {

  var formContents = jQuery(this).serializeArray();           
  var formSource = jQuery(this).find('input[type="submit"]').attr("alt");
}

Then this should work as expected. and yes to your questions.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.