Closed lcsqlpete closed 7 years ago
Here you go:
<button id=demo_btn1>Inception</button>
<script>
(function(window, document){
var btnCb = function() {
$.ajax({url: "dummy.json", success: function(result) {
var list = document.createElement('ul');
var _cb = function(i, ds) {
var keys = Object.keys(ds);
keys.forEach(function(k){
if (typeof ds[k] !== "object") {
var tmp = document.createElement('li');
tmp.innerHTML = k + " : " + ds[k];
list.appendChild(tmp);
}
});
};
$(result).each(_cb);
$(list).appendTo('body').modal();
}});
};
demo_btn1.onclick = btnCb;
})(window, document);
</script>
Great, thanks Marco. In my case, I'll already have the modal defined on the page, just need to fill in some elements on it from the ajax call. I assume I can use a similar technique? Pete
On Mon, Jul 24, 2017 at 2:33 AM, Marco Kellershoff <notifications@github.com
wrote:
Here you go:
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/kylefox/jquery-modal/issues/209#issuecomment-317369853, or mute the thread https://github.com/notifications/unsubscribe-auth/AIGhFKnFmsjYxtJj4j5_1IxrL24Z2f2Kks5sRGUDgaJpZM4OgljN .
That is not related to this plugin, but anyway, here you go:
<button id=demo_btn1>Inception</button>
<div style="display:none" id=oldschool_w_rapper>
<form>
<input type="email" value="" />
</form>
</div>
<script>
(function(window, document){
var btnCb = function() {
$.ajax({url: "dummy.json", success: function(result) {
var $form = $(oldschool_w_rapper).children().eq(0);
$form.find('input').eq(0).val(result[0].email);
$form.modal();
}});
};
demo_btn1.onclick = btnCb;
})(window, document);
</script>
Working example is here
Thanks, will try it.
On Tue, Jul 25, 2017 at 12:47 AM, Marco Kellershoff < notifications@github.com> wrote:
That is not related to this plugin, but anyway, here you go:
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/kylefox/jquery-modal/issues/209#issuecomment-317657825, or mute the thread https://github.com/notifications/unsubscribe-auth/AIGhFNDa8vGFbG86MRJJI785e6hR_BQvks5sRZ19gaJpZM4OgljN .
I'm hoping to convert an existing page on my website to use jquery-modal. It's a form for purchasing concert tickets. The data is loaded into the form using an Ajax call to get it from a database. I see ajac examples but they all seem to be aimed at reading the form layout from an external file rather than loading data into it.
Any pointers to get me on the right track much appreciated.