Hello T.J. I'd like to share that parameter was successfully passed through onCreate handler, before each update. Yet, as you envisioned, I now see double highlights when the mouse moves.
The problem with the JSON approach is that, right now, the table layout is generated in the jsp page. If I use JSON, does that mean I have to re-write tickets.jsp (to output the raw data of the tickets in JSON format) and put all the formatting logic in javascript? Many thanks for you help, and the time you spent. Debbie On May 22, 3:41 am, "T.J. Crowder" <[EMAIL PROTECTED]> wrote: > Hi Debbie, > > If you hook the onCreate handler, you can modify the parameters before > they're sent to the request. So you could supply the ID of the > currently-highlighted row and send it to the server side, which could > assign whatever class does the highlighting or what have you. (Of > course, there's no guarantee that the user won't have moved the mouse > before the request is completed.) By the time onCreate is called, the > parameters have been parsed into a Hash object, which makes it easy to > add to them: > > onCreate: function(resp) { > resp.request.options.parameters.idToHighlight = > findHighlightedRowID(); > > } > > I don't know whether this is likely to change in future versions. > > You can also change the responseText in the onComplete handler; this > is triggered before the update is done, so your changes will be used. > The downside there is that you have to parse through the text to find > the element, but at least you don't have to worry that the highlighted > row ID is out of date. > > So that answers the question you asked. But another approach you > might consider would be for the server side to return the ticket list > as an array of objects in JSON format rather than as HTML. Then you > could compare to the list you already have and only change the display > (insert rows, remove rows, or update row contents) as necessary, > rather than tearing down and rebuilding the display on every update, > which might make for less flicker overall -- and of course in the > process, if you do have to update the highlighted row, you can handle > the highlighting issue client-side and not have to worry about the > user moving the mouse during the request. (And the JSON for the > tickets is likely to be smaller than the HTML to represent the > tickets, making for less traffic.) For this you'd probably use a > PeriodicalExecuter: Create the request, send it off, handle the JSON > in the reply. FWIW. > > Hope this helps, > -- > T.J. Crowder > tj / crowder software / com > > On May 21, 8:57 pm, Debbie <[EMAIL PROTECTED]> wrote: > > > > > Hello All, > > > I have the following code: > > > myAjax = new Ajax.PeriodicalUpdater("div", "tickets.jsp", { > > evalScripts: true, > > parameters: queryString > > }); > > > Tickets.jsp displays rows of data obtained from a database. Each row > > is color coded. For example, red for failed tickets, gray for > > expired, etc. When the mouse hovers over a row, it gets hightlighted > > in orange via onmouseover event in the tr element in tickets.jsp. > > > The problem is after each update, the browser doesn't remember the > > pointer position before the update and the highlight dissappears. > > I've used javascript to keep track of the row id and change its color > > after the update. However, when the page updates, the color has to > > change from its original color to orange. As a result, the > > highlighted row blinks with each update. > > > I don't like the blinking. Creating a new ajax object upon each mouse > > move (with the row id stored in a hidden field for example) will > > likely solve the problem. But that's not what I like either. > > > Ideally, I would like to pass the row id before the page is generated, > > so that the original color of that row can be set to orange. The > > question is: is there a way to pass it to the ajax so that it can be > > used before each XMLhttpRequest is sent? > > > As a last resort, would modifying transport.response work? > > > Thanks a lot for your time.- Hide quoted text - > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---