title: Trigger function when button is clicked but before submission
body: <p>I am swapping out the contents of one wysiwyg editor into another before submission. I have been doing this by wrapping the submit button in a div and using the mouseenter event to fire it.</p>
  
  <pre><code>&lt;div id="moveit"&gt;
  &lt;input type="button" name="sq_commit_button" id="sq_commit_button" value="Commit" accesskey="s" class="sq-form-field sq-btn-large sq-btn-green sq-commit-button" onclick="if (submit_form) { submit_form(this.form); } else { this.form.submit(); this.disabled = 'disabled';}  "&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>and</p>
  
  <pre><code>jQuery('#moveit').mouseenter(function() {
      jQuery('#news_item_0_1162_wysiwyg_div #htmlarea iframe').contents().find('html').html(jQuery('#cke_1_contents iframe').contents().find('html body').html());
  });
  </code></pre>
  
  <p>This has worked just fine for now, but is by no means a long term solution. Is there a way to execute the function when the button is clicked but before it submits, so the content can be copied across?</p>
  
  <p>I tried using the onsubmit function, but when I look, the wysiwyg editor doesn't seem to consist of any form elements.</p>
  
  <pre><code>$('#myform').submit(function() {
    // your code here
  });
  </code></pre>
  
  <p>The only instance of a form on the page looks like this, and I have tried the following form id and name in an onsubmit function without any luck.</p>
  
  <pre><code>&lt;form id="page_asset_builder_1427599" name="main_form" method="post" action="http://example.com/builder/_nocache?" enctype="multipart/form-data" onsubmit="return form_on_submit()"&gt;
  </code></pre>
  
  <p>Can anyone suggest how I could do this? Or should I just stick with my mouseenter method and try and forget about it</p>
  
  <p>Thanks so much!</p>