How do use dojo TextBox attr function to get value?

若如初见. 提交于 2019-12-08 19:48:01

问题


How can i get the value of a Dojo TextBox?

Am doing this;

dijit.byId("textName").getValue();

But firbug tells me getValue() is deprecated! is use attr('value')!

but i have no clue on how to use attr('value') function

Help

Gath


回答1:


Starting with Dojo 1.5 you should use the get and set methods to fetch and set properties. But the attr method is still working until Dojo 2.0 is out.

var box = dijit.byId('textbox')
box.get('value');
box.set('value', 'new value');



回答2:


I've done this and its working;

var titleEdit = dijit.byId('title');

var myValue = title.attr('displayedValue');

worked!




回答3:


In 1.2, Dijit moved to a common attribute accessor scheme. To use the new style and avoid the warning do this instead:

dijit.byId("textName").attr("value");

The lead for Dijit wrote up a good blog post on attr that might help.



来源:https://stackoverflow.com/questions/735384/how-do-use-dojo-textbox-attr-function-to-get-value

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!