Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jan 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ajax, updating a table order

    using a table created from an ajax-returned dataset like this:

    1 id#1
    2 id#2
    3 id#3 -> currently editing

    i have a textbox that allows a user to move the position of the item "currently editing" by recreating the ajax dataset and rebuilding the table.

    the order of the items is then saved to a DB thru another ajax call.

    the problem. shifting the items and saving to the DB works find once, but any attempt to save the items again resulst in the javascript code reading the table that was saved previously.

    so if i save the table as
    1 id#1
    2 id#3
    3 id#2

    and then shift the table to
    1 id#3
    2 id#1
    3 id#2

    the javascript function will pick up the order as being stuck as the top one.
    i am guessing that my problem is the DOM is not updating, and i need to refresh it, but i cannot use a typical page refresh (ajax constraint). anyone have any advice on this?

    code:

    function saveItemOrder()
    {
    var env = getEnv();
    var user = getUser();
    //read the table for items and order, submit each to ajax call to upd item
    var itemId;
    var itemOrderNum;
    var itemOrderTbl = document.getElementById('tblItemOrder');

    var arItemOrder = " ";
    for (var i=0; i<itemOrderTbl.rows.length;i++)
    {
    var iRow = itemOrderTbl.rows[i];
    itemId = iRow.id.split("x")[1];
    itemOrderNum = itemOrderTbl.rows[i].cells[1].innerHTML;
    var itemIdOrderNum = itemId + "|" + itemOrderNum + "|";
    if (i != 0)
    {
    arItemOrder += itemIdOrderNum;
    }
    else
    {
    arItemOrder = itemIdOrderNum;
    }

    }
    alert(arItemOrder);
    WebPubHome.saveItemOrderwAR(env, user, arItemOrder, callback_saveItemOrder);

  • #2
    Senior Coder
    Join Date
    Jul 2005
    Location
    New York, NY
    Posts
    1,084
    Thanks
    4
    Thanked 19 Times in 19 Posts
    Well, it appears that you're relying on the state of the dom to tell you what order things are in, no?

    Though, re-reading your post, I'm not completely sure what the problem is.

  • #3
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    To me it sounds like maybe your Ajax request is being cached by the browser.

    Do something with a timestamp if you are using get or change it to a post.

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #4
    New to the CF scene
    Join Date
    Jan 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i may have misinterpreted the source of my problem. need to do some more testing, and am debated on reworking my approach. in case you'd like me to clarify what i was talking about accomplishing:

    i dynamically create a table where each row correspondes to one object in a list. the number of objects is drawn by the returning dataset of a select statement. that's what this is:
    Table
    Cell Cell
    _____________________
    |Object 1 | ID for obj 1 | |textbox| |button|
    |Object 2 | ID for obj 2 |
    |____________________|
    etc.

    user is 'editing' object 2, row is highlighted to show this, user can enter a new position in the list for the object, (example, user puts a 1 in the textbox, clicks the button, and object #2 moves to the first row, pushes the other rows down)

    then user can save the order to the database to retain.

    problem was, it was saving the updated order once, but requests to save mutiple times were not updating, they were all coming in the way the first time the user saved. but there may be a couple possible errors in code, i'll need to go through and figure it all out. thanks for your time anyway, and if anyone wants more info or code sample let me know.

    also, to note, i'm developing in .net, and using the dll found here: http://ajax.schwarz-interactive.de/v...e/default.aspx


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •