[Vtigercrm-developers] jQuery.Class and extend()

Prasad prasad at vtiger.com
Tue Jun 24 20:34:17 GMT 2014


Your are right about the reference link, one more here:
http://bitovi.com/blog/2010/06/a-simple-powerful-lightweight-class-for-jquery.html

Vtiger_List_Js.extend('WorldClock_List_Js', { /* static methods */ }, {
>  /* class methods */
> ...
> });


Closest php equivalent would be:
class WorldClock_List_JS extends Vtiger_List_Js {}

If you are on the (WorldClock module, List view) - client-side framework of
Vtiger
tries to instantiate the controller (WorldClock_List_Js) if exists
otherwise loads (Vtiger_List_Js).

Defining key with same name in either static methods / class methods block
lets you override
the parent's behavior. (World-Clock example
<http://community.vtiger.com/help/vtigercrm/developers/extensions/examples/world-clock-v1.html#step-7-view-javascript>
overrides registerEvents class method).


*Connect with us on: *Twitter <http://twitter.com/vtigercrm> *I* Facebook
<http://www.facebook.com/pages/vtiger/226866697333578?sk=wall> *I* Blog
<https://blogs.vtiger.com/>* I* Wiki
<http://wiki.vtiger.com/index.php/Main_Page> *I *Forums
<https://discussions.vtiger.com>*I* Website <https://www.vtiger.com/>


On Wed, Jun 25, 2014 at 1:29 AM, Alan Lord (News) <alanslists at gmail.com>
wrote:

> Hi guys,
>
> Are there any *useful* examples/documentation of this?
>
> The only reference to $.Class I can find is here:
> http://v3.javascriptmvc.com/docs/#&who=jQuery.Class But I am not sure if
> this the same code as is being used in vtiger?
>
> What I'm trying to understand is, for example in your Worldclock example,
> you show the following:
>
>  Vtiger_List_Js.extend('WorldClock_List_Js', {}, {
>> ...
>> });
>>
>
> Now, from my very rudimentary understanding this means that I am creating
> a "clone" (if you like) of Vtiger_List_Js that also contains the functions
> and parameters defined in WorldClock_List_Js.
>
> What I am trying to understand is if I create a function in
> WorldClock_List_Js that has the same name as the original in Vtiger_List_Js
> will my new one override it?
>
> What are the limitations and catches with this approach?
>
> My reason for these questions is I'm wanting to override a few functions
> in Vtiger_List_Js and add a few more. I'd really like to not have to create
> a whole copy of the Vtiger_List_Js class in my module if I can help it...
> But I can't seem to get it to work. Maybe I am misunderstanding something?
>
> Thanks
>
> Al
>
>
>
> --
> Libertus Solutions
> http://www.libertus.co.uk
>
> _______________________________________________
> http://www.vtiger.com/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20140625/0f82b389/attachment.html>


More information about the vtigercrm-developers mailing list