와 모달 폼을 채울 :내가 이렇게 만든 모달 폼을 JSON
function addeditNote(rowID,callback) {
var ret;
jQuery.fancybox({
modal : true,
overlayOpacity : 0.25,
content : "<div class=\"contentbox modal-window modal-400\"><div class=\"boxbody\"><div class=\"boxheader clear\"><h2>Add/Edit User Notes</h2></div><br /><div class=\"box-wrap clear\"><form action=\"\" method=\"post\" class=\"form bt-space0\"><div class=\"columns clear bt-space0\"><div class=\"colText fl\"><div class=\"form-field clear\"><label for=\"textfield\" class=\"formlabel size-20 fl-space2\">Name: </label><input type=\"text\" id=\"name\" class=\"text fl-space2\" /></div><div class=\"form-field clear\"><div class=\"fl-space2\"><label for=\"textarea\" class=\"formlabel size-20\">Notes: </label></div><textarea id=\"note\" class=\"form-textarea display\" cols=\"50\" rows=\"6\" name=\"form[note]\" rel=\"textarea\"></textarea></div></div></div><div class=\"columns clear bt-space5\"></div><div class=\"form-field clear\"><input id=\"addeditNote_cancel\" class=\"button fr-space2\" type=\"button\" value=\"Cancel\"><input id=\"addeditNote_ok\" class=\"button green fr-space\" type=\"button\" value=\"Enter\"></div></form></div><!-- end of box-wrap --></div> <!-- end of box-body --></div>",
onComplete : function() {
jQuery("#addeditNote_cancel").click(function() {
ret = false;
jQuery.fancybox.close();
})
jQuery("#addeditNote_ok").click(function() {
ret = true;
jQuery.fancybox.close();
})
},
onClosed : function() {
callback.call(this,ret);
}
});
}
내가 얻을 내 JSON 문자열 같은 : 반환
$.getJSON("GetNotes.php?id=" + rowID,
function(data) {
$.each(data, function(i, item) {
$('#' + item.field).val(item.value);
});
});
:
{"op": "UPDATE", "id": "7","name": "Joe Public","note": "Dennis likes his coffee in the morning... He doesn't drink tea and coffee always have powdered creamer and 2 sugar's." }
"op"는 단지 자리 표시 자이므로 메모가 존재한다면 데이터베이스를 업데이트하고 삽입하지 않으면 ...
내 문제가, 나는 양식을 채우려면이 넣어 whwre 모른다 ... 나는 아직도이 어떻게 작동하는지 누군가가 나에게 단서를 얻을 수 있습니다 .. :)
감사를 기대했다 배우고! 데니스
양식 요소 이름이 json 개체 속성과 일치합니까? – jondavidjohn
예 .. 함수 내에서 창을 생성하는 경우 호출 할 수 있는지 확실하지 않습니다. – Dennis