Working example of registry.findWidgets()

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Working example of registry.findWidgets()

Zemljoradnik
Can someone give me a working example of registry.findWidgets()? Whatever I do, I keep getting an empty array. For example:

<div id="root"></div>

require(["dijit/form/TextBox", "dijit/registry", "dojo/domReady!"], function(TextBox, registry){
    var myTextBox = new dijit.form.TextBox({
        name: "firstname",
        value: "" /* no or empty value! */,
        placeHolder: "type in your name"
    }, "root");
   
    console.log(registry.findWidgets('root'))
});
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Working example of registry.findWidgets()

Kenneth G. Franqueiro
IIRC findWidgets searches *under* the given node; however, your code is
creating a textbox widget *replacing* that node.  Hence findWidgets has
nothing to find.

If you were to do the following instead, to place the textbox widget as
the last child of the DOM node, findWidgets should find your widget:

var myTextBox = new TextBox({
  ...
}).placeAt("root");
myTextBox.startup();

--Ken

On 10/10/2013 10:34 AM, Zemljoradnik wrote:

> Can someone give me a working example of registry.findWidgets()? Whatever I
> do, I keep getting an empty array. For example:
>
> <div id="root"></div>
>
> require(["dijit/form/TextBox", "dijit/registry", "dojo/domReady!"],
> function(TextBox, registry){
>     var myTextBox = new dijit.form.TextBox({
>         name: "firstname",
>         value: "" /* no or empty value! */,
>         placeHolder: "type in your name"
>     }, "root");
>    
>     console.log(registry.findWidgets('root'))
> });
>
>
>
> --
> View this message in context: http://dojo-toolkit.33424.n3.nabble.com/Working-example-of-registry-findWidgets-tp3999612.html
> Sent from the Dojo Toolkit mailing list archive at Nabble.com.
> ________________________________________________________
> Dojo Toolkit: http://dojotoolkit.org/
> Tutorials: http://dojotoolkit.org/documentation/
> Reference Guide: http://dojotoolkit.org/reference-guide
> API Documentation: http://dojotoolkit.org/api
>
> [hidden email]
> To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
>
________________________________________________________
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/
Reference Guide: http://dojotoolkit.org/reference-guide
API Documentation: http://dojotoolkit.org/api

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Working example of registry.findWidgets()

Zemljoradnik
My example was wrong, but I've already tried what you're suggesting, and I've tried it once again, and it still gives me an empty array. Here's the jsfiddle: http://jsfiddle.net/FYYqx/1/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Working example of registry.findWidgets()

Zemljoradnik
Turns out registry.findWidgets() accepts only DOM node, not a string, as most methods in dojo do. I tried that, but I must have made a mistake the first time. Anyway, thanks for pointing out this other mistake I made.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Working example of registry.findWidgets()

rrakhmetov
In reply to this post by Zemljoradnik
Zemljoradnik, you should wrap dom self first befor find:



require(["dojo/dom","dijit/form/TextBox", "dijit/registry", "dojo/domReady!"],
function(dom,TextBox, registry){
    var myTextBox = new dijit.form.TextBox({
        name: "firstname",
        value: "" /* no or empty value! */,
        placeHolder: "type in your name"
    }).placeAt("root");

    console.log(registry.findWidgets(dom.byId('root')))
});


On Thu, Oct 10, 2013 at 5:04 PM, Zemljoradnik <[hidden email]> wrote:
My example was wrong, but I've already tried what you're suggesting, and I've
tried it once again, and it still gives me an empty array. Here's the
jsfiddle:  http://jsfiddle.net/FYYqx/1/ <http://jsfiddle.net/FYYqx/1/>



--
View this message in context: http://dojo-toolkit.33424.n3.nabble.com/Working-example-of-registry-findWidgets-tp3999612p3999616.html
Sent from the Dojo Toolkit mailing list archive at Nabble.com.
________________________________________________________
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/
Reference Guide: http://dojotoolkit.org/reference-guide
API Documentation: http://dojotoolkit.org/api

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest



--
Met vriendelijke groeten,

Ramil Rakhmetov


PEOPLEWARE
Duwijckstraat 17
2500 Lier - Belgium
+32 3 448.33.38  Facebook   Twitter
www.peopleware.be

________________________________________________________
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/
Reference Guide: http://dojotoolkit.org/reference-guide
API Documentation: http://dojotoolkit.org/api

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Working example of registry.findWidgets()

ManX
This post has NOT been accepted by the mailing list yet.
This post was updated on .
+ rrakhmetov :  after even so many years, your post is helpful and perhaps if you will , add a little more to clear the block in my brain  en. re.  Dojo

It seems to me that the Node "id" must be known and added to the dojo function:
require(["dojo/dom","dijit/form/TextBox", "dijit/registry", "dojo/domReady!"],
function(dom,TextBox, registry){
    var myTextBox = new dijit.form.TextBox({
        name: "firstname",
** My guess is that when the page loads, the <node> with an attribute of "name" equal to "firstname" is added to the registry.  But my HTML is generated and dojo is applied to the HTML framework. **


My Question and Confusion with AMD:
A.)  How are nodes added to the registry?  
(e.g. are nodes manually added to registry, are nodes tagged and get added to registry)

B.)  My platform is Modular, and the dojo - dijit  code is not all in one <script>  tag area.  
Code related to each module is in that module.  

~ thank you for your consideration or anyone elses' consideration.
ManX

Loading...