views:

59

answers:

1

hi.

using mootools, and have the follwoing test. the test has an initial function that traps the 'submit' event from the form, so the submit btn invokes the window.addEvent function. this works.

i'm trying to figure out how to call the window.addEvent function from a separate javascript function, ie the saveCollegedata function.

in looking over sites via the net, haven't come up with the correct approach to do this. though about doing a document.forms['myform'].submit(), but that doesn't work..

also thought about doing an onSubmit from the form and calling a different javascript function, but not quite sure how this would work, to be able to also use the "this.send" in the ajax callback.

    function saveCollegeData()
    {
        var t;
        t="tt";
        alert("t="+t);
//          window.top.fireEvent('domready');
//          document.forms["adminForm"].submit();
        t="tt";

    }

    //-generate the 2nd coldata frm to mod the data
    //-uses the mod-collegedata1.frm page
    //-user confirms the data
    window.addEvent('domready', function() {

    $('adminForm').addEvent('submit', function(e) {
        //Prevents the default submit event from loading a new page.
        new Event(e).stop();
        //alert (foo);
        alert ('11111111aaaa ');
        //--clear out the div to start.. just in case..
        clearJorge();

        //--set/reset the task item to the task for 
        //--the server side.. was set to "" for the toolbar
        //-- the "this" should refer to the $('adminForm') form
        this.task.defaultValue="mdata2";
        .
        .
        .
A: 

use the fireEvent() method ( http://mootools.net/docs/core/Element/Element.Event#Element:fireEvent )

$("adminForm").fireEvent("submit");

$("adminForm").submit(); should also work

there's a chance you may need to pass on an object like this with the fireEvent():

element.fireEvent("submit", {
    stop: $empty
}); 

you would do this if you have an event.stop() in the callback. similarly, event.target or any other property you may refer to needs to be simulated.

although sort of thing this is more valid for 1.2.x whereas you are probably on 1.1x where it goes through the Event object instance.

Dimitar Christoff