Thanks for the tip! I've made the change. I have one last issue that
maybe someone can help me with. Once I make the ajax.request, the
request doesn't finish before moving on in my code and returning the
wrong note.id.
Every new note starts with a note.id = 1. Once the "save" button is
clicked performs the ajax.request and save it to the DB. Then I want
to return the new PK and change the page's note.id = newPK. The
problem is that I can't get the ajax.request to finish before moving
on through my function.
Here's my updated code that does save correctly and return the new PK
correctly. It just doesn't return it in time. Notice at the bottom I
have "return note.id". This still always returns a value of 1. I have
in my onSuccess note.id = transport.responseText. This does change the
note.id correctly..just not in time! Help again! Thanks guys. (also, I
tried changing the onSuccess to onComplete and that didn't work
either.)

function saveNoteDb(note){
    note.Save();
    var url = 'saveNote.aspx';
    var ajaxinsert= new Ajax.Request(url, {
    method: 'get',
    parameters: {
        text: note.text,
        width: note.rect.width,
        height: note.rect.height,
        left: note.rect.left,
        top: note.rect.top,
        id: note.id,
        status: note.status},
        onSuccess: function(transport) {

        if (transport.responseText > 0)
        {
        //note saved
        note.status = 'saved';
        note.id = transport.responseText;
        }
        else
        {
        note.status = 'failed';
        }
    }
    });
    return note.id;
    }
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to