Very Simple Inline Editing

2009-04-16

I wanted inline editing for Mammon (and eventually Eldmyra), but after looking around on the net I was disappointed at the libs available. The only one I found that looked somewhat reasonable had all the code in portugese or something. Note to aspiring developers: always write code in English. Anyway, after some fiddling I present to you Very Simple Inline Editing:

  1. Include the following script file: http://static.eldmyra.se/js/inline_edit.js (requires the Prototype JS library)
  2. Mark up the parts you want to edit. So if you before had {{my_variable}} change it to:
    <span class="inline_editable" edit_url="/path_to_server_side_command/" id="{{my_variable}}_id">
    {{my_variable}}
    </span>

    Note that you need a unique id on the tag.
  3. Implement the server side handler. The new data comes as a parameter ”new_content” in the POST request. Whatever is returned from the server side is inserted into the element when it’s done.

And that’s it!

– Möller

Annonser

Kommentera

Fyll i dina uppgifter nedan eller klicka på en ikon för att logga in:

WordPress.com Logo

Du kommenterar med ditt WordPress.com-konto. Logga ut / Ändra )

Twitter-bild

Du kommenterar med ditt Twitter-konto. Logga ut / Ändra )

Facebook-foto

Du kommenterar med ditt Facebook-konto. Logga ut / Ändra )

Google+ photo

Du kommenterar med ditt Google+-konto. Logga ut / Ändra )

Ansluter till %s

%d bloggare gillar detta: