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
    Aug 2014
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Dynamically Generating a Form on a Definition List

    I would like to have a form after clicking a definition list by using JQuery. Say,
    Code:
    <dl>
      <dt>abc</dt>
      <dd>123<dd>
      <dt>xyz</dt>
      <dd>321<dd>
    </dl>
    To edit one item in the list, I would like to change the list item to a form by clicking somewhere on the item. I am wondering how to achieve this goal. If I use the JQuery $("#aBlockId").html("<form ...> .... </form>") approach, I need to wrap the item with a div tag and assign a block ID. How to dynamic generate a such ID and retrieve them?

  • #2
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,984
    Thanks
    56
    Thanked 557 Times in 554 Posts
    sounds complicated. why not just make them contenteditable?
    Code:
    <dl>
      <dt contenteditable>abc</dt>
      <dd contenteditable>123<dd>
      <dt contenteditable>xyz</dt>
      <dd contenteditable>321<dd>
    </dl>

  • #3
    New to the CF scene
    Join Date
    Aug 2014
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by xelawho View Post
    sounds complicated. why not just make them contenteditable?
    Code:
    <dl>
      <dt contenteditable>abc</dt>
      <dd contenteditable>123<dd>
      <dt contenteditable>xyz</dt>
      <dd contenteditable>321<dd>
    </dl>
    Thanks very much for your input.

    I assume that I need a Javascript Ajax code to syn up an edited data on the page and the data in the back. Any code sample you can recommend?

  • #4
    New to the CF scene
    Join Date
    Aug 2014
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Also, I need to have CSS IDs for each fields if I use JQuery to retrieve data in the fields. My HTML code is dynamically generated (by Thymeleaf). Any special ID format I shall use and how those IDs can be stated in JQuery?


  •  

    Posting Permissions

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