问题描述
我想使用 dijit / Editor
允许用户在表单上输入格式化的文本。该文档位于。我在表单上设置了 div ,并为HTML编辑器添加了属性。
I want to use dijit/Editor
to allow users to enter formatted text on a form. The documentation is here. I set up a div on my form and added attributes for the HTML Editor.
<label for="eed-event-description" class="required">Event Description</label><br />
<div id="eed-event-description" data-dojo-type="dijit/Editor" height="120px" title="required: brief description of what someone attending can expect at the event" required>
<p></p>
</div>
这会导致很多新代码,包括iframe:
This results in a lot of new code, including an iframe:
<iframe id="eed-event-description_iframe" style="border: medium none; width: 100%; height: 120px;" title="Event Description" src="javascript: '<!DOCTYPE html><html lang=\'en\'>
<head>
<meta http-equiv=\'Content-Type\' content=\'text/html\'>
<title>Event Description</title><style>
body,html {
background:transparent;
padding: 1px 0 0 0;
margin: -1px 0 0 0;
}
body,html,#dijitEditorBody { outline: none; }html { height: 100%; width: 100%; overflow: hidden; }
body,#dijitEditorBody { height: 100%; width: 100%; overflow: auto; }
body{
top:0px;
left:0px;
right:0px;
font:400 16px "Lucida Sans Unicode", Arial, Helvetica, sans-serif;
line-height:1.125;
}
p{ margin: 1em 0; }
li > ul:-moz-first-node, li > ol:-moz-first-node{ padding-top: 1.2em; }
li{ min-height:1.2em; }
</style>
</head>
<body role=\'application\' aria-label=\'Event Description\'onload=\'try{frameElement && frameElement._loadFunc(window,document)}catch(e){document.domain="id0129.vps.sonic.net";frameElement._loadFunc(window,document)}\' style=\'\'><div id=\'dijitEditorBody\' role=\'textbox\' aria-multiline=\'true\' aria-label=\'Event Description\'></div></body>
</html>'" class="dijitEditorIFrame" frameborder="0"></iframe>
我不知道如何引用用户添加文本的区域,并且我在告诉我如何在JavaScript中处理结果。如何获取此文本?
I don't know how to reference the area where the user adds text, and I don't see any documentation on dojotoolkit.org that tells me how to pick up the results in JavaScript to process. How do I get this text ?
推荐答案
dijit / Editor
具有方法以获取其HTML区域内容,
The dijit/Editor
has the .get('value') method in order to get it's HTML area content ,
因此,您只需通过使用 dijit / registry
并使用函数来获取dijit的引用。
So you can simply get a reference of your dijit by using dijit/registry
and the use the function .
var myEditor = registry.byId("eed-event-description");
var htmlValue = myEditor.get('value');
请参阅此演示
这篇关于如何从dijit / Editor获取内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!