1、增加字段类型
2、修复增加字段时的一处bug
This commit is contained in:
@@ -14,7 +14,7 @@ define(['jquery', 'bootstrap', 'validator'], function ($, undefined, Validator)
|
||||
'italic', 'underline', 'strikethrough', 'lineheight', 'image', 'media', 'table'
|
||||
],
|
||||
},
|
||||
fieldlisttpl: '<dd class="form-inline"><input type="text" name="<%=name%>[<%=index%>][key]" class="form-control" value="<%=row.key%>" size="10" /> <input type="text" name="<%=name%>[<%=index%>][value]" class="form-control" value="<%=row.value%>" /> <span class="btn btn-sm btn-danger btn-remove"><i class="fa fa-times"></i></span> <span class="btn btn-sm btn-primary btn-dragsort"><i class="fa fa-arrows"></i></span></dd>'
|
||||
fieldlisttpl: '<dd class="form-inline"><input type="text" name="<%=name%>[<%=index%>][key]" class="form-control" value="<%=row.key%>" size="10" /> <input type="text" name="<%=name%>[<%=index%>][value]" class="form-control" value="<%=row.value%>" /> <% if (row.other) { %><input type="text" name="<%=name%>[<%=index%>][other]" class="form-control" value="<%=row.other%>" /><% } %> <span class="btn btn-sm btn-danger btn-remove"><i class="fa fa-times"></i></span> <span class="btn btn-sm btn-primary btn-dragsort"><i class="fa fa-arrows"></i></span></dd>'
|
||||
},
|
||||
events: {
|
||||
validator: function (form, success, error, submit) {
|
||||
@@ -397,16 +397,18 @@ define(['jquery', 'bootstrap', 'validator'], function ($, undefined, Validator)
|
||||
return true;
|
||||
}
|
||||
var template = $(this).data("template");
|
||||
var json = {};
|
||||
var json = [];
|
||||
try {
|
||||
json = JSON.parse(textarea.val());
|
||||
var d = textarea.val().split(/[\n,]/g);
|
||||
d.map(function(item, i){
|
||||
json.push(item.split(":"))
|
||||
})
|
||||
// json = JSON.parse(textarea.val());
|
||||
} catch (e) {
|
||||
}
|
||||
$.each(json, function (i, j) {
|
||||
$(".btn-append,.append", container).trigger('click', template ? j : {
|
||||
key: i,
|
||||
value: j
|
||||
});
|
||||
var item = (j.length > 0) ? {key:j[0],value:j[1],other:j[2]} : {key:i,value:j[0]};
|
||||
$(".btn-append,.append", container).trigger('click', template ? j : item);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user