我已经创建了一个自定义标记,现在我正在尝试获取自定义属性的值,我尝试了很多方法,出于某种原因警报返回undefind ...谢谢你们。自定义标记选择.attr返回undefined
<goladmin:select cssClass="shortSelect"
path="textType"
items="${textTypeList}"
itemValue="id"
itemLabel="description"
widgetType="widget"
onchange="true"
multiple="false" />
的JavaScript
<script language="javascript" type="text/javascript">
$(document).ready(function() {
//call to get the widget type
getWidgetType();
//On select dropdown change
$('#textType').change(function(){
var wt = $('#textType').val();
alert("widgetType=" + wt);
//call to get the widget type
//getWidgetType();
});
});
function getWidgetType(){
var value = $('#textType').val();
//set hidden textTypeWidget to the selected widget
$('#textTypeWidget').val(value);
//get the widget type value from the hidden field
var widgetType = $('#textTypeWidget').val();
// show and hide the editor based on the widget type
if(widgetType == "CKEDITOR") {
$('#ckEditorEditor').show();
$('#textAreaEditor').hide();
}else{
$('#ckEditorEditor').hide();
$('#textAreaEditor').show();
}
}
生成的HTML
<select id="textType" name="textType" class="shortSelect" onchange="true"><option value="1" selected="selected"></option><option value="2">button label</option><option value="3">title</option><option value="4">error message</option><option value="5">link text</option><option value="6">url</option><option value="7">label</option><option value="8">text</option><option value="9">table title</option><option value="10">help text</option><option value="11">question text</option><option value="12">answer text</option><option value="13">question help text</option><option value="14">glossary</option><option value="15">information mesage</option><option value="16">confirmation message</option><option value="17">system message</option></select>
生成的HTML设定项目值时小部件....
<select id="textType" name="textType" class="shortSelect" onchange="true"><option value="TEXTAREA" selected="selected"></option><option value="TEXTAREA">button label</option><option value="CKEDITOR">title</option><option value="TEXTAREA">error message</option><option value="TEXTAREA">link text</option><option value="TEXTAREA">url</option><option value="TEXTAREA">label</option><option value="TEXTAREA">text</option><option value="TEXTAREA">table title</option><option value="CKEDITOR">help text</option><option value="CKEDITOR">question text</option><option value="CKEDITOR">answer text</option><option value="TEXTAREA">question help text</option><option value="CKEDITOR">glossary</option><option value="CKEDITOR">information mesage</option><option value="CKEDITOR">confirmation message</option><option value="CKEDITOR">system message</option></select>
可以共享生成的HTML? –
对不起,我没有明白...谁或什么是#textTypeWidget? –
textTypeWidget将是我将基于textType显示给用户的编辑器的类型......我知道我的问题是什么,我需要为textTypeWidget的自定义标记添加一个新属性,以便让我做到这一点。生成HTML应该基本看起来像这样 – Korda