title: javascript, calling a class which contains a constructor to setup click events etc?
body: <p>i am trying to organize my javascript. What i would like to do is have a class for each PAGE rather then just entering javascript straight into a js - is this good practice?</p>
  
  <p>Let me explain .. thinking a long of the lines of, i would really appreciated any input, good or bad and ideas on my variable naming... of remember that this a kind of class so i have to create the class   but then i must call it...(see below) ... i am using the prototype + constructor pattern.</p>
  
  <pre><code>// THIS FILE WILL BE SAVED as RESERVATIONPAGE
  function ReservationPage(){
      // Setup click events in this constructor
      $('submit-button').bind('click',this.submit_click);
  
      $('clear-button').bind('click',this.clear_click);
  
      // setup other variables   
  }
  
  ReservationPage.prototype = {
        constructor: ReservationPage,
        submit_click : function () {
              alert(' you just clicked the submit button');
        },
        clear_click : function () {
              alert('button for clearning the form fields!!');
        }
  };
  </code></pre>
  
  <p>Then each page will need a standard js file i.e. not a class / object to instantiate their Page js like above..., so a kind of entry point -  so hence</p>
  
  <pre><code>// THIS FILE WILL BE SAVED as ReservationLoad - notice the word Load :-) -- don't know if this is good naning convetion, anybody suggest anything different??
  
  var reservationPage = new ReservationPage(); // CREATES NEW INSTANCE OF THE CLASS/OBJECT ..
  </code></pre>
  
  <p>I don't any other way of doing it, i would really appreciate any input. I will be using jquery extensively but this shouldn't matter.....   I need a standard JS file - no objects to instantiate my objects hence I called in load....  this in turn instantiates the object and calls the constructor..</p>
  
  <p>The constructor sets up the click events and then calls the methods</p>
  
  <p>Is this good,</p>
  
  <p>Any idea where i am going wrong..</p>
  
  <p>I really appreciate some input, i am little lost...... and want to do it right... I am coming from a c# .net background.....  and i know js isn't  a proper OOP language but i am trying to treat it like this for better structuring...</p>
  
  <p>This way, all my js files are separate from my HTML and my CSS:.. there is no events entered into the html... they are all entered via code</p>
  
  <p>Look forward to any info</p>