でモーダルフォームを移入:は、私がこのように作成されたモーダルフォームを持っている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文字列を取得します:
{"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." }
を:返す
$.getJSON("GetNotes.php?id=" + rowID,
function(data) {
$.each(data, function(i, item) {
$('#' + item.field).val(item.value);
});
});
私は知っているので、私はデータベースを更新しているし、私はそれを挿入している場合は、私が知っているので、 "op"ちょうどプレースホルダー..
私の問題は、私は、フォームを移入するためにこれを入れてwhwreかわからない、です..私はまだので、誰かが私にこれがどのように機能するかの手掛かりを与えることができる期待していた勉強.. :)
感謝を! デニス
あなたのフォームの要素名はjsonオブジェクトのプロパティと一致しますか? – jondavidjohn
はい..私は関数内から私がウィンドウを生成しているかどうかを呼び出すことができるかどうか分かりません – Dennis