dojoX
dojoX

Reputation: 1615

Associating a dojoAttachpoint to a div created dynamically?

I want to create a div dynamically and want to attach a dojoAttachpoint. How can i do so?

Following code is used to add a div dynamically, but i want to attach a dojoAttachpoint too

var txt = dojo.create("div", {
    id: "alert",
    role: "alert",
    'class': "contenthide",
    innerHTML: msg
}, dojo.body());

Upvotes: 2

Views: 1169

Answers (2)

Andrew Ferrier
Andrew Ferrier

Reputation: 17732

Generally, you shouldn't need to. The dojoAttachPoint's purpose to allow you to get an unambigious handle onto the div within your dijit when it's declared declaratively (particularly important if you are creating more than one of your dijit on the same page).

However, because you are creating the div dynamically, you already have the handle - in your case, the variable txt. This will perform the same function. If you need it to become a property of your dijit, just create one:

this._myDivsPseudoAttachPoint = txt;

Upvotes: 1

Andrei
Andrei

Reputation: 4237

As i know, you can use dojoAttachPoint only in widget template string dojo-what-is-a-widget

dojoAttachPoint, dojoAttachEvent, waiRole, waiState attributes documentation

Upvotes: 0

Related Questions