Joined March 2014
·

Alexis Rabago Carvajal

Chetumal Quintana Roo
·
·
·

thank you for your reply, about the superi-ing in the "constructor" we prevent using super in it because the extending class NewFolderView reference a "new" view, which means it has no Id or Name yet, it is a form with a "parentfolderid" only, we wanted it for a file-tree system so it became a need to have many extending classes for a folder like, EditFolderView, NewFolderView, etc...

about the @prototype... well, i have not found any problems on using it but yes @template_path would be accessed using it as a normal global variable and not prototypal like this:

template_path = "path/to/template" 

this way we may not need to call it as:

@prototype.template_path

as you say calling it with @prototype may have some issues but i have not found any yet, it may enlighten me if you could give me some info about problems using it.


EDIT

Correcting myself:

after trying the change in my answer 2 problems may colide:

if we add it as a global variable:

template_path = "path/to/template"

under the inherited @template method it would become unable to use the "newfoldertemplate" variable

TAKING A LOOK AT RENDERED JAVASCRIPT

@template: ->

is using refference to the class it is declared into (FolderView), when we see it in javascript it is:

FolderView.template = function() {
    return JST[this.prototype.template_path];
};

and the template path prototypal variables are:

NewFolderView.prototype.template_path = "path/to/new_folder_view";
FolderView.prototype.template_path = "path/to/folder_view

Now looking at the inherited javascript it has no @template function/method because the inheriting class relies in EXTENDING/INHERITING only.

then when we call:

NewFolderView.folder_html(parent_id)

the NewFolderView makes the function work in it's own scope, calling its own version of the template_ path under @template via the @prototype.template_ path

Achievements
106 Karma
8,722 Total ProTip Views