本文介绍了Dojo:以编程方式设置要在TableContainer上添加的复选框标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

经过几个小时的文档检查后,我有些绝望了:
基本上我需要用一些TextBoxes和一些Checkbox填充TabContainer。所有这些整齐地排列:左侧的标签,右侧的字段。

为此,我使用添加到TabContainer的TableContainer,创建TextField并将其添加到TableContainer。一切都很好。但是当涉及到复选框时,我根本找不到显示标签的窍门。
如果我:
-向创建语句添加标签属性,则说:

var text8 = new dijit.form.CheckBox({

id: zuschauer_ + i,值: zuschauer,标签: fritt}));

Firefox提出了 containerNode为null-错误

after some hours of checking out documentation, I am somewhat desperate:Basically I need to populate a TabContainer with some TextBoxes, and some Checkboxes. All theses neatly arranged: Labels to the left, fields to the right.
To have this done I use a TableContainer that I add to the TabContainer, create the TextFields and add them to the TableContainer. All is rendered ok. But when it comes to a checkbox, I can't find the trick to have a label displayed at all.If I:- add a label-attribute to creation statement say:
var text8 = new dijit.form.CheckBox({
id:"zuschauer_" + i, value: "zuschauer", label:"fritt"});
Firefox comes up with a "containerNode is null" - Error


  • 尝试添加标签:未显示任何内容(没有错误,但是可惜:没有标签):

    var text9 = dojo.create('< label>');

    dojo.attr(text9, for, zuschauer_ + i);

    dojo.attr(text9, content, fritt) ;

  • try to add a tag: Nothing is shown (no error, but alas: no label):
    var text9 = dojo.create('<label>');
    dojo.attr(text9,"for","zuschauer_" + i);
    dojo.attr(text9,"content","fritt");

尝试在表容器上添加div或其他内容(禁用标签):Firefox出现:
错误:未捕获的异常:[Exception ...组件返回的失败代码:0x80004003(NS_ERROR_INVALID_POINTER)[nsIDOMHTMLDivElement.appendChild] nsresult: 0x80004003(NS_ERROR_INVALID_POINTER)位置: JS框架:: ...

try to add a div or somewhat else on the tablecontainer (disabled Labels): Firefox comes up whith:Error: uncaught exception: [Exception... "Component returned failure code: 0x80004003 (NS_ERROR_INVALID_POINTER) [nsIDOMHTMLDivElement.appendChild]" nsresult: "0x80004003 (NS_ERROR_INVALID_POINTER)" location: "JS frame :: ...

对于创建的TextNode来说是相同的...

same is for created TextNodes...

因此,如何破解:

-我会以编程方式为复选框生成标签吗(无法使用html模板,我已经看过周围的代码,创建了一个复选框,但之前在html上有一个 label for。这对我没有帮助。我不知道我在设计时需要多少个复选框。这些复选框将在运行时完全生成。

-我可以通过编程方式完成这个非常简单的设计吗?一定很容易,这不是火箭的沉默。

So how the hack:
- Would I generate a label to a checkbox programatically (no html template possible, I've seen the code around, creating a checkbox but having a 'label for' on the html before. This would not be helpful, as I don't know how many checkboxes I need at designtime. These are to be genereated completly at runtime.
- Would I have this very simple design done programatically, Must be easy, this is not rocket sience. Do I really need the TableContainer to have this done?


  • 我真的可以需要 TableContainer吗?在TableContainer中创建静态文本?

  • Can I create static text in a TableContainer?

推荐答案

在这种情况下,您可能希望使用匿名LABEL( HTML)标签。您可以将文本放在输入/小部件之前或之后,并可以使用样式/ dir属性对其进行定位。由于您在解析时不需要ID,因此可以提供更多的灵活性。只需创建一个标签标签,然后将其放入表单小部件即可。它是纯HTML,自HTML 4.01起应受支持。

In such cases you may want to use the input/widget inside an anonimous LABEL (HTML) tag. You can put the text before or after the input/widget, and probably position it using style/dir attributes. This will allow some more flexibility, as you don't need an ID at parse time. Just create a label tag and throw in your form widget. It is pure HTML and should be supported since HTML 4.01.

另请参阅:

这篇关于Dojo:以编程方式设置要在TableContainer上添加的复选框标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 14:22