Results 1 to 1 of 1

Thread: Best practice for keeping modular Javascript simple

  1. #1
    Join Date
    Apr 2006
    Posts
    205
    Thanks
    11
    Thanked 0 Times in 0 Posts

    Cool Best practice for keeping modular Javascript simple

    I'm buidling a Javascript application that's become quite complicated. I'm increasingly getting stuck when debugging it.

    I'll describe one issue I've been facing as best I can. I have a module that adds and removes sets of HTML elements within a form. I have another module that reorders those sets, and a third module that updates their index values (e.g. IDs and form input names).

    In some instances these sets contain other elements that have modules associated with them, for example images and image spaces in the form trigger a popup to open with an image upload fields and an image editor module.

    The popup-image-editor module uses the ID of the set it belongs to, in order to scroll that set into view when it pops up. This is fine except, when the user reorders the sets because the module has already defined it's own configs with the ID it had in it's original position. When it's been reordered the ID the module is using no longer relates to that set but to another set that's sitting in the targetted set's original position.

    It sounds complicated an in many ways that's why I'm writing this post. I'm looking for help, tips, ideas, advice on keeping module JS simple. I think I've hit a point where this is more complex than I'm used to and would appreciate some input.

    One idea I have to solve this specific problem is to have the indexing module publish a topic/message when it's finished reindexing. The popup/image-editing modules could subscribe to this topic and update the IDs in their configs when this topic is published.

    Does anyone have any ideas on the best way to solve this particular decision point? And can anyone make any suggestions to help me keep my JS applications well organised, if not simple.

    Thanks in advance!
    Last edited by dog; 09-04-2015 at 09:21 PM. Reason: Attempt to make the question/post clearer

Similar Threads

  1. Is this good practice?
    By Burgin in forum CSS
    Replies: 2
    Last Post: 05-11-2010, 03:22 PM
  2. Sport practice
    By JVposter in forum The lounge
    Replies: 6
    Last Post: 02-21-2009, 02:08 AM
  3. FK'd column naming best practice
    By brentnicholas in forum MySQL and other databases
    Replies: 1
    Last Post: 11-18-2008, 05:14 AM
  4. Bad CSS practice?
    By Moshambi in forum CSS
    Replies: 6
    Last Post: 11-24-2007, 09:56 PM
  5. [DHTML] Modular Scroller (Scrollable content script III)
    By jscheuer1 in forum Submit a DHTML or CSS code
    Replies: 12
    Last Post: 08-17-2006, 10:34 PM

Tags for this Thread

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
  •