[Dojo-interest] Extending My custom Widget in 1.7.1 (Error : mixin #2 is not a callable constructor)

107 views
Skip to first unread message

swapnil22589

unread,
Feb 7, 2012, 9:39:05 AM2/7/12
to dojo-i...@mail.dojotoolkit.org
Hi all,
I have created on widget which takes care of i18n in my application
(parentLabel.js)

now i m extending this widget to create new templated widget (label.js)

In this i am facing one error "mixin #2 is not a callable constructor" in
dojo.js
i am not able to identify exact coz of this error

My project structure is
http://dojo-toolkit.33424.n3.nabble.com/file/n3722666/custom1.jpg

My base widget is
http://dojo-toolkit.33424.n3.nabble.com/file/n3722666/custom4.jpg

My widget(label) which extends base widget(parentLabel) is

http://dojo-toolkit.33424.n3.nabble.com/file/n3722666/custom3.jpg

My index page is
http://dojo-toolkit.33424.n3.nabble.com/file/n3722666/custom2.jpg


finally error which i am getting is
http://dojo-toolkit.33424.n3.nabble.com/file/n3722666/custom5.jpg

Plz see to it,
and plz reply ASAP.

Waiting for reply ..

-----
Regards,
Swapnil :)
--
View this message in context: http://dojo-toolkit.33424.n3.nabble.com/Extending-My-custom-Widget-in-1-7-1-Error-mixin-2-is-not-a-callable-constructor-tp3722666p3722666.html
Sent from the Dojo Toolkit mailing list archive at Nabble.com.
________________________________________________________
Dojotoolkit: http://dojotoolkit.org
Reference Guide: http://dojotoolkit.org/reference-guide
API Documentation: http://dojotoolkit.org/api
Tutorials: http://dojotoolkit.org/documentation

Dojo-i...@mail.dojotoolkit.org
http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest

Karl Tiedt

unread,
Feb 7, 2012, 10:49:26 AM2/7/12
to dojo-i...@mail.dojotoolkit.org
you arent returning your widgets in your files... for AMD you have to
return the object you expect to be usable from that file... ie: return
declare("myNewWidget, [..... ], ......);

-Karl Tiedt

swapnil22589

unread,
Feb 8, 2012, 12:02:44 AM2/8/12
to dojo-i...@mail.dojotoolkit.org
Thanx Karl Tiedt,

i am having one query regarding your reply.
as u said, Is it compulsory to have return in code if we need to extend our
widget?

coz my above error ("mixin #2 is not a callable constructor") solved by ur
suggestion (ie. when i written return in parentLabel )
eg.
return declare("parentLabel",
[_WidgetBase],{
_i18n: i18n,
....

and in label.js

function(declare,_WidgetBase,_TemplatedMixin, parser,ready, parentLabel){

declare("label",
[_WidgetBase,_TemplatedMixin,parentLabel],{
templateString:"<div> ${translatedLabel}</div>"
......


in this case my lifecycle method are executed properly with out error.
but templateString is not rendered on page..

===========================================================

where as in other case i tried with

return declare("parentLabel",
[_WidgetBase],{
_i18n: i18n,
....

and

-----
Regards,
Swapnil :)
--

View this message in context: http://dojo-toolkit.33424.n3.nabble.com/Extending-My-custom-Widget-in-1-7-1-Error-mixin-2-is-not-a-callable-constructor-tp3722666p3724903.html


Sent from the Dojo Toolkit mailing list archive at Nabble.com.

swapnil22589

unread,
Feb 8, 2012, 2:15:00 AM2/8/12
to dojo-i...@mail.dojotoolkit.org
Hey , i got my code working,
changes i done are

in parentLabel.js
1)return statment (eg. return define("parentLabel"...... )
+
2) also added _TemplatedMixin in parentLabel.js


http://dojo-toolkit.33424.n3.nabble.com/file/n3725087/parentLabel.jpg

in label.js
no return statment..

==========================

code is working but my understanding is still not clear..
1) why to return from our widget..
and if in child class i m using return code is not running..

2) also one new question i came across.
if i want to specify template in child , is it necessory to have
_TemplatedMixin in base class??
coz when i have not putted it in my base class, template html was not
rendering
and after putting it is renderring..

-----
Regards,
Swapnil :)
--

View this message in context: http://dojo-toolkit.33424.n3.nabble.com/Extending-My-custom-Widget-in-1-7-1-Error-mixin-2-is-not-a-callable-constructor-tp3722666p3725087.html

Kitson Kelly

unread,
Feb 8, 2012, 2:33:09 AM2/8/12
to dojo-i...@mail.dojotoolkit.org
On 8 February 2012 07:15, swapnil22589 <swapni...@gmail.com> wrote:
Hey , i got my code working,
changes i done are

in parentLabel.js
1)return statment (eg. return define("parentLabel"......  )
+
2) also added _TemplatedMixin in parentLabel.js


http://dojo-toolkit.33424.n3.nabble.com/file/n3725087/parentLabel.jpg

in label.js
no return statment..





==========================

code is working but my understanding is still not clear..
1) why to return from our widget..
and if in child class i m using return code is not running..


You aren't directly using the return code, but the loader and the define are using the return from your function to create the necessary constructor/prototype to be used by the application and registered as a module.
 
2) also one new question i came across.
if i want to specify template in child , is it necessory to have
_TemplatedMixin in base class??
coz when i have not putted it in my base class, template html was not
rendering
and after putting it is renderring..


Simple answer is yes.  That is exactly what the _TemplatedMixin does, adds support for a template to your Widget.

Reply all
Reply to author
Forward
0 new messages