Little background ...
I have an object called SineMacula in which there are many methods for creating form elements and creating these form elements on a page.
Firstly, when the page loads, a method called setFields() called, which setFields() over all the fields on the page and accordingly sets them ie autocomplete, checkbox, etc.
The code for setFields() as follows:
SineMacula.prototype.setFields = function (options){
Most of the code above can be ignored, but I inserted all of this so that you can see exactly what I'm doing.
My question
I have quite a few SineMacula object methods like setCheckbox() , setDropdown() ...
What would I like to know if I should consider these methods as objects in myself?
So should my code look like this:
if($(this).parent().hasClass('autocomplete')){ new SineMacula.dropdown($(this).parent(),{source:$(this).attr('data-source')}); }
Note the new keyword before calling dropdown() .
Is this the best working method? Will less memory be used, etc.
source share