There are two variants of the submit function. If you call $('#rpt').submit(); you are firing the "submit" event of the form. If you call $('#rpt').submit(myFunctionName); You are binding myFunctionName to the "submit" event of the form. This will not be fired when the page loads, but only when you try to submit the form. As such, this code:
<form id="rpt" method="GET" action="http://www.google.com/search">
Search: <input type="text" name="q"> <input type="submit" value="Go">
</form>
And this Javascript:
function myFunctionName() {
alert('The form is being submitted!');
return false; // cancel the event (ie, the form will not be sent)
}
$(function() {
$('#rpt').submit(myFunctionName);
});
Will call the myFunctionName function only when the form is submitted (either by manually pressing the "Go" button or by pressing enter when the text field is focused). Here is a sample of it at work. If you want to run a particular function when the page loads, all you have to do is pass something to the $(document).ready(); function, or $() for short:
function onLoadDoThis() {
alert('Page is loaded!');
}
$(document).ready(onLoadDoThis); // $(onLoadDoThis); is the same thing
And here is an example of this. Hope this cleared some stuff up...
EDIT
Ok, so I whipped up a working example of what you are trying to do. At first I was annoyed you couldn't get this to work, but there were actually quite a number of limitations you have to work around because of how crappy this editor is. Anyways, onto the explanation:
The first problem is that the library overrides the use of $ to its own little function. So the jQuery awesomeness is not possible the regular way. Thankfully, jQuery is awesome and you can get around that by doing something like this:
$j = jQuery.noConflict();
Now instead of doing $(...); you have to do $j(...);. If you are not aware of this it is likely you were trying to write jQuery code and nothing was happening.
The next hurdle you were probably having is that for most events, when you do something like $(selector).myevent(aFunction); it is assumed that doing $(selector).myevent(); will fire said event. However, this is not true of the submit event. Unless the form action is triggered by a user the code you bind to the submit of a form won't be called when the form is submitted by code. So even though the line in the source code of the editor that does form.submit(); is simply firing the native submit event of the form, even if you bind an event to this event with Javascript it won't be called in this circumstance because the user didn't trigger the submit event, code did.
Due to this limitation, it gets increasingly tricky to achieve what you want without editing the source code of the editor. You see, the editor attaches its "create all the dashboard crap" stuff to the window's load event. This event fires after jQuery's DOM ready event, as the whole point of jQuery's ready is to fire as soon as possible and not a second later, while window.load takes its sweet time. So what we have to do is ditch the jQuery bind code (grimace) and use the editor's own binding code to attach an event directly afterwards its own "create the dashboard" function. At this point, the dashboard has already been created so we can access the Save button and make it do what we want - only after removing its original event of calling the 'Save' function you found in the source code.
At the end of the day, the code ends up looking like this:
$j = jQuery.noConflict(); // give up ownership of $ to WYSIWYG
WYSIWYG.attach('textarea1', full); // first attach the event to create this widget
WYSIWYG_Core.addEvent(window, "load", function() {
// and now override the Save button
// the removeAttr('onclick') is crucial to stop it
// from doing what it normally does (Which is submit the form)
$j('#Save').removeAttr('onclick').click(function() {
var form = $j('#myform');
var data = form.serialize();
var type = form.attr('method');
var url = form.attr('action');
$j.ajax({
url: url,
type: type,
data: data,
dataType: 'json',
success: function(d) {
if(d.success == 1) {
$j('#notice').html('Everything went alright! High fives.');
} else {
$j('#notice').html('Something went wrong. Eep.');
}
}
});
});
});
While my_handler.php is a very simple script that just returns a json string:
<?php
// process your stuff here, set success as 1 or 0
$success = 1;
print json_encode(array('success' => $success));
?>
And here is an example of it in action.
Personally, I really don't like this particular editor and I would suggest you check out something else.
Either way, though, I hope this helped.