Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I've been asking similar questions lately (<a href="https://stackoverflow.com/questions/251814/jquery-and-organized-code">here</a> and <a href="https://stackoverflow.com/questions/247209/javascript-how-do-you-organize-this-mess">here</a>) and I've found a couple things that can help. I understand the same issues that you're finding with UI interaction being forced into code.</p> <p><strong>1:</strong> Write "classes" for the functionality and pass in the elements to modify in the constuctor, whether it's the ID for the element or the element itself, up to you.</p> <p><strong>2:</strong> Write "events" for the sections that may vary depending on the page or control. By events, I mean just placeholder methods that you can overwrite with actual functions. So for examples...</p> <pre><code>var FilterControl = function() { //the "event" var self = this; this.onLoadComplete = function() { }; //This is the command that calls the event this.load = function() { //do some work ... //Call the event self.onLoadComplete(); }; }; //somewhere else in the code var filter = new FilterControl(); filter.onLoadComplete = function() { //unique calls just for this control }; </code></pre> <p><strong>3:</strong> Get an IDE that is more Javascript friendly. I <strong>love</strong> my Visual Studio, but <a href="http://apanta.com" rel="nofollow noreferrer">Apanta</a> makes a outstanding IDE that has a really powerful Javascript IDE (it allows you to drag .JS files into a <em>File References</em> dialog so you get intellisense for all those Javascript documents solving one of the main reasons why it's hard to split up Javascript!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload