mirror of
https://github.com/processwire/processwire.git
synced 2025-08-12 09:44:38 +02:00
Update inputfields.js for better error handling and improved reload support
This commit is contained in:
@@ -2349,17 +2349,27 @@ function InputfieldReloadEvent(event, extraData) {
|
|||||||
consoleLog('Inputfield reload: ' + fieldName);
|
consoleLog('Inputfield reload: ' + fieldName);
|
||||||
$.get(url, function(data) {
|
$.get(url, function(data) {
|
||||||
var id = $t.attr('id');
|
var id = $t.attr('id');
|
||||||
var $content = jQuery(data).find("#" + id).children(".InputfieldContent");
|
var $content;
|
||||||
if(!$content.length && id.indexOf('_repeater') > -1) {
|
if(data.indexOf('{') === 0) {
|
||||||
id = 'wrap_Inputfield_' + fieldName;
|
data = JSON.parse(data);
|
||||||
|
console.log(data);
|
||||||
|
$content = '';
|
||||||
|
} else {
|
||||||
$content = jQuery(data).find("#" + id).children(".InputfieldContent");
|
$content = jQuery(data).find("#" + id).children(".InputfieldContent");
|
||||||
if(!$content.length) {
|
if(!$content.length && id.indexOf('_repeater') > -1) {
|
||||||
console.log("Unable to find #" + $t.attr('id') + " in response from " + url);
|
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($content.length) {
|
||||||
// if(typeof jQuery.ui != 'undefined') $t.effect("highlight", 1000);
|
$t.children(".InputfieldContent").html($content.html());
|
||||||
$t.trigger('reloaded', [ 'reload' ]);
|
//InputfieldStates($t);
|
||||||
|
InputfieldsInit($t);
|
||||||
|
$t.trigger('reloaded', ['reload']);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user