设置Dijit.Form.Textarea的值 [英] Set Value of Dijit.Form.Textarea

查看:285
本文介绍了设置Dijit.Form.Textarea的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个dijit对话框,其中包含一个我要自动填充的表单。我可以使用其中的表单来显示对话框,但是我无法设置表单中的文本区域的值。这是包含html的div。

 < div dojoType =dijit.Dialogid =formDialogtitle =Form Dialog> 
< table>
< tr>
< td>
< label for =desc>
说明:
< / label>
< / td>
< td>

< textarea id =descname =descdojoType =dijit.form.Textareastyle =width:200px;>< / textarea>






SAVE


关闭






我可以通过执行



var formDlg = dijit.byId(formDialog);
formDlg.show();



但我的问题是设置textarea的值为desc。我已经尝试过多个东西,但是我知道我需要

  var test = dijit.byId(desc); 

但如果我设置任何测试属性,例如

  test.value =foo; 
test.textContent =foo;
test.innerHTML =foo;
test.srcNodeRef =foo;

该值永远不会保存并显示在textarea内。有这样做的伎俩吗?任何帮助都会很棒。谢谢

解决方案

  var test = dijit.byId(desc); 
test.set(value,foo);

..应该做的伎俩,我想。 Dojo中的大多数小部件使用方法(以前 attr )设置属性值,而不是直接像您一样操纵它们我试图做。您还可以通过传递一个对象来一次设置多个属性:

  var test = dijit.byId(desc); 
test.set({value:foo,name:someName});


I have a dijit dialog that contains a form that I want to auto-populate. I can get the dialog to display with the form in it, but I have been unable to set the value of a text area within the form. Here is the div that houses the html.

<div dojoType="dijit.Dialog" id="formDialog" title="Form Dialog" >
<table>
    <tr>
        <td>
            <label for="desc">
                Description:
            </label>
        </td>
        <td>

        <textarea id="desc" name="desc" dojoType="dijit.form.Textarea" style="width:200px;"></textarea>

SAVE CLOSE

I can get this to display just fine by doing

var formDlg = dijit.byId("formDialog"); formDlg.show();

But the issue I have is setting the value of the textarea called "desc". I have tried multiple things, but I know I need to

var test = dijit.byId("desc");

but if I set any property of test, such as

   test.value = "foo";
   test.textContent = "foo";
   test.innerHTML = "foo";
   test.srcNodeRef = "foo";

The value is never saved and displayed inside the textarea. Is there a trick to doing this? Any help would be great. Thanks

解决方案

var test = dijit.byId("desc");
test.set("value", "foo");

..should do the trick, I think. Most widgets in Dojo use the set method (formerly attr) to set property values, instead of manipulating them directly like you've tried to do. You can also set multiple properties in one go by passing an object:

var test = dijit.byId("desc");
test.set({"value": "foo", "name": "someName"});

这篇关于设置Dijit.Form.Textarea的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆