#1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    204
    Rep Power
    3

    [jQuery] Element creation (best practice?)


    Hi! Small question..

    When a user select a point on google map the options panel has to open.. now is the best practice to already make the panel and hide it .. and then show()

    or is it better to create the elements .. add them to the DOM using jquery when the user clicks the button

    thanks!
  2. #2
  3. A Not To Shabby Code Smurf
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Aug 2008
    Posts
    1,183
    Rep Power
    184
    Is the "option panel" dynamic or static? If it is dynamic (made on the fly) and has multiple options/interaction features; I would build it with DOM (especially if your getting JS, JSON, JSONP, XML, etc. data from Google). Otherwise; if it was static and had limited options/interaction features; I would pre-build and show/hide element. Just my opinion; as "I am a non-attorney spokesperson" jk (seen to many lawyer commericals lately lol), but no (for real)..., yeah; that would be my approach, but I cannot speak to what W3C's outlined recommendation is... to your/their Q&A.
  4. #3
  5. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    204
    Rep Power
    3
    Originally Posted by web_loone08
    Is the "option panel" dynamic or static? If it is dynamic (made on the fly) and has multiple options/interaction features; I would build it with DOM (especially if your getting JS, JSON, JSONP, XML, etc. data from Google). Otherwise; if it was static and had limited options/interaction features; I would pre-build and show/hide element. Just my opinion; as "I am a non-attorney spokesperson" jk (seen to many lawyer commericals lately lol), but no (for real)..., yeah; that would be my approach, but I cannot speak to what W3C's outlined recommendation is... to your/their Q&A.
    Thanks for the nice response! When u select a marker on the google maps, in the flyout panel, you can choose which icon you want it to have and you can add a description.. So there is interactivity, but it's always the same interactivity.. I'm gonna take a look on how to build elements from the DOM. doesn't seem easy
  6. #4
  7. A Not To Shabby Code Smurf
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Aug 2008
    Posts
    1,183
    Rep Power
    184
    Originally Posted by notflip
    I'm gonna take a look on how to build elements from the DOM. doesn't seem easy
    It may look complicated, at first; but once you get it down... it's a piece of cake.

IMN logo majestic logo threadwatch logo seochat tools logo