mirror of
https://ghproxy.net/https://github.com/elementor/wp2static.git
synced 2025-09-05 12:02:54 +08:00
WIP saving all form data to backend
This commit is contained in:
parent
1402ae939c
commit
d279786f39
2 changed files with 23 additions and 27 deletions
|
@ -4,6 +4,8 @@
|
|||
*
|
||||
* Copyright (c) 2011 Leon Stafford
|
||||
*/
|
||||
|
||||
error_log('loading options page');
|
||||
?>
|
||||
|
||||
<?php
|
||||
|
@ -71,32 +73,17 @@ jQuery(document).ready(function($){
|
|||
console.log('number of archives: ' + numberOfArchives);
|
||||
|
||||
|
||||
var newSettings = {};
|
||||
$(".options-form").serializeArray().map(function(x){newSettings[x.name] = x.value;});
|
||||
//var newSettings = {};
|
||||
//$(".options-form").serializeArray().map(function(x){newSettings[x.name] = x.value;});
|
||||
var newSettings = $(".options-form").serialize();
|
||||
|
||||
console.log(newSettings);
|
||||
|
||||
// stick json encoded settings into hidden field within form(s)
|
||||
$(".hiddenSettingsField").val(newSettings);
|
||||
|
||||
// base data on first form, so as to include nonces
|
||||
data = $(archives[0]).serialize();
|
||||
|
||||
|
||||
console.log(data);
|
||||
|
||||
$.ajax({
|
||||
url: ajaxurl,
|
||||
data: data,
|
||||
dataType: 'html',
|
||||
method: 'POST',
|
||||
success: function(serverResponse) {
|
||||
console.log('options saved');
|
||||
$('#results').append(serverResponse);
|
||||
}
|
||||
});
|
||||
|
||||
$('#progress').hide();
|
||||
// just submit form as usual
|
||||
$(archives[0]).submit();
|
||||
}
|
||||
|
||||
$('#generateArchiveButton').click(function() {
|
||||
|
@ -112,22 +99,22 @@ jQuery(document).ready(function($){
|
|||
//$('#formActionHiddenField').val('generate')
|
||||
});
|
||||
|
||||
$('#saveSettingsButton').click(function() {
|
||||
$('.wrap').on('click', '.saveSettingsButton', function(event) {
|
||||
// TODO: needed prevention?
|
||||
event.preventDefault();
|
||||
|
||||
$('#progress').show();
|
||||
|
||||
saveOptions();
|
||||
|
||||
$('#results').html('');
|
||||
|
||||
});
|
||||
|
||||
// TODO: set to on body event with button class as target, else need to reattach handler!
|
||||
$('.wrap').on('click', '.addAnotherTargetButton', function(event) {
|
||||
// TODO: needed prevention?
|
||||
event.preventDefault();
|
||||
|
||||
// check for max of 5 forms (in DB)
|
||||
|
||||
// append copy of form below current one
|
||||
$('.options-form:last').clone().insertAfter('.options-form:last');
|
||||
|
||||
|
@ -210,7 +197,7 @@ jQuery(document).ready(function($){
|
|||
<?php wp_nonce_field($this->onceAction) ?>
|
||||
<input id="formActionHiddenField" class="hiddenActionField" type="hidden" name="action" value="generate" />
|
||||
<input name="staticExportSettings" class="hiddenSettingsField" type="hidden" name="action" value="" />
|
||||
<input id="saveSettingsButton" class="button-primary" value="Save current options" />
|
||||
<input class="saveSettingsButton button-primary" value="Save current options" />
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue