これは私がjQueryを使って遊んでいた最初の1週間なので、多くの質問があります。jqueryダイアログと編集フォームの記入
私はアイテムの作成と編集の両方に1つのダイアログを使用しています。
私の関数editCustomField()はフィールド名を入力する必要はないと思っていましたが、ダイアログを開きます。
jQueryの代わりにjavascript getElementById( "empId")などを使用する必要がありますか?関数を動作させるために、関数をjQueryタグの形式でラップすることはできますか?リンクはjstlとelを使用して構築されます。
<script type="text/javascript">
function editCustomField(empId, fieldId, name, value){
$("empId").val(empId);
$("fieldId").val(fieldId);
$("fieldName").val(name);
$("fieldValue").val(value);
$("#customFieldDialog").dialog("open");
return false;
};
$(document).ready(function(){
$("#customFieldDialog").dialog({
resizable: false,
modal: true,
autoOpen: false,
width:315,
buttons: {
"Save" : function() {
$("#customFieldForm").submit();
},
"Cancel" : function() {
$(this).dialog("close");
return false;
}
}
});
$(".customfield").click(function(e) {
$("#customFieldDialog").dialog("open");
});
});
</script>
HTML:
<a href="#" onclick="editCustomField('${employee.id}','${viewCustomField.id}','${viewCustomField.name}','${viewCustomField.value}');"><img src="<c:url value="/images/pencil.png"/>" alt="edit" title="edit" /></a>
<div id="customFieldDialog" title="Custom Field">
<form id="customFieldForm" action="saveCustomField.action" method="POST">
<input type="hidden" id="empId" name="employeeId" />
<input type="hidden" id="fieldId" name="customFieldId" />
<table>
<tr>
<td>Field name:</td><td><input id="fieldName" type="text" name="customField.name" /></td>
</tr>
<tr>
<td>Value:</td><td><input id="fieldValue" type="text" name="customField.value" /></td>
</tr>
</table>
</form>
</div>
機能が間違っていた...ああよく –