SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Pandora Tipem's Avatar
    Join Date
    Feb 2006
    Posts
    450
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Ajax "listeners"

    Hi guys,

    I'm new to AJAX and a lot of Javascript concepts. What I'm trying to do is add a constant "listener" to one of my pages. Basically what I'd like to do is have a textarea on a page and whenever somebody hits "Edit Textbox" it will lock the textbox for everybody else that's on that page at that exact moment. When the edit is complete, it will "unlock" the textbox and be available to editing then (the sole purpose of "locking" and "unlock" the textbox is to prevent 2 people from editing it at once, so there isn't any data loss). So, yeah, I figure that this would require some type of AJAX listener or something like that to be constantly checking for this info. How would I go about doing this? And where should I store the "textbox status" information (e.g., in a database or flat-file)?

    I'm using jQuery which may make this process a heckuva lot easier btw. Feel free to post the DOM if you'd like, I could easily "translate" it into jQuery... I think.

    Thanks in advanced.
    Tipem no fancy sig, yup
    Need Neopets Help? Try Neopets
    fun adoptable eggs

  2. #2
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I hope you realise that this could be bypassed by simply disabling javascript. A better way of going about this would be to do it like Wikipedia does (on the server side). If you make submit your changes and someone has submitted changes to the same revision before you did (i.e. while you were typing), you get a message saying "someone has made these changes" and then you are asked what you want to do about it. It would be much less hassle to do it like this and probably more user-friendly. If you disable the textarea people might think the system is broken, that they've been banned or something like that. Also consider what would happen if someone opened the "edit" page and then left for a few hours, leaving that page open. It would be blocked for everyone else for those hours and nobody would get anything done.

  3. #3
    Pandora Tipem's Avatar
    Join Date
    Feb 2006
    Posts
    450
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ahhh, I see. This is a great point. Yeah, I should just keep track of the revisions in a database and compare them whenever somebody makes a change. Thanks for the idea.
    Tipem no fancy sig, yup
    Need Neopets Help? Try Neopets
    fun adoptable eggs


Bookmarks

Posting Permissions

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