This commit is contained in:
Ziver Koc 2016-05-25 20:30:40 +02:00
parent 7109abeea2
commit 17e50573d6
6 changed files with 36 additions and 17 deletions

View file

@ -113,11 +113,13 @@
// Set dynamic data
modal.find("select[name=type]").val(button.data("type"));
modal.find("select[name=type]").change(); // Update dynamic inputs
$.each(button.attr(), function(name, value) {
if(name.startsWith("data-")) {
name = name.substring(5);
console.log(name, value);
modal.find("input[name="+name+"]").val(value);
$.each(button.attr(), function(fieldName, value) {
if(fieldName.startsWith("data-")) {
fieldName = fieldName.substring(5);
// case insensitive search
modal.find("input").filter(function() {
return this.name.toLowerCase() == fieldName;
}).val(value);
}
});
});

View file

@ -28,6 +28,7 @@ $(function(){
};
})($.fn.attr);
// converts all timestamps to human readable time and date
$.fn.relTimestamp = function() {
return this.each(function() {
var timestamp = parseInt($(this).text());

View file

@ -215,11 +215,14 @@
// set dynamic form data
modal.find("select[name=type]").val(button.data("type"));
modal.find("select[name=type]").change(); // Update dynamic inputs
$.each(button.attr(), function(name, value) {
if(name.startsWith("data-")) {
name = name.substring(5);
console.log(name, value);
modal.find("input[name="+name+"]").val(value);
$.each(button.attr(), function(fieldName, value) {
if(fieldName.startsWith("data-")) {
fieldName = fieldName.substring(5);
console.log(fieldName, value);
// case insensitive search
modal.find("input").filter(function() {
return this.name.toLowerCase() == fieldName;
}).val(value);
}
});
});