将dojoAttachpoint与动态创建的div相关联?

编程入门 行业动态 更新时间:2024-10-24 14:28:06
本文介绍了将dojoAttachpoint与动态创建的div相关联?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想动态创建一个div,想附加一个dojoAttachpoint。我可以这样做吗?

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

以下代码用于动态添加div,但我也想附加一个dojoAttachpoint

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());

推荐答案

一般来说,你不需要。 dojoAttachPoint 的目的是允许您在声明性声明的情况下,将您的dijit中的 div 特别重要的是,如果您在同一页面上创建多个dijit)。

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).

但是,因为您正在创建 div 动态地,你已经有了句柄 - 在你的情况下,变量 txt 。这将执行相同的功能。如果您需要它成为您的dijit的财产,只需创建一个:

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;

更多推荐

将dojoAttachpoint与动态创建的div相关联?

本文发布于:2023-10-19 14:46:35,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1507834.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:相关联   动态   dojoAttachpoint   div

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!