1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-11 09:14:58 +02:00

Update inputfields.js for better error handling and improved reload support

This commit is contained in:
Ryan Cramer
2022-10-06 13:14:55 -04:00
parent 32d7a09cfd
commit 96bb90bb2e
2 changed files with 19 additions and 9 deletions

View File

@@ -2349,17 +2349,27 @@ function InputfieldReloadEvent(event, extraData) {
consoleLog('Inputfield reload: ' + fieldName);
$.get(url, function(data) {
var id = $t.attr('id');
var $content = jQuery(data).find("#" + id).children(".InputfieldContent");
if(!$content.length && id.indexOf('_repeater') > -1) {
id = 'wrap_Inputfield_' + fieldName;
var $content;
if(data.indexOf('{') === 0) {
data = JSON.parse(data);
console.log(data);
$content = '';
} else {
$content = jQuery(data).find("#" + id).children(".InputfieldContent");
if(!$content.length) {
console.log("Unable to find #" + $t.attr('id') + " in response from " + url);
if(!$content.length && id.indexOf('_repeater') > -1) {
id = 'wrap_Inputfield_' + fieldName;
$content = jQuery(data).find("#" + id).children(".InputfieldContent");
if(!$content.length) {
console.log("Unable to find #" + $t.attr('id') + " in response from " + url);
}
}
}
$t.children(".InputfieldContent").html($content.html());
// if(typeof jQuery.ui != 'undefined') $t.effect("highlight", 1000);
$t.trigger('reloaded', [ 'reload' ]);
if($content.length) {
$t.children(".InputfieldContent").html($content.html());
//InputfieldStates($t);
InputfieldsInit($t);
$t.trigger('reloaded', ['reload']);
}
});
event.stopPropagation();
}

File diff suppressed because one or more lines are too long