Edit.js
1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/**
* Created by ty on 2016/7/6.
* 活动分享编辑
*/
var $ = require('jquery'),
common = require('../../../common/common');
var id = $("#edit-content").data("id"),
url = $("#edit-content").attr("url"),
module = {},
edit = new common.edit2("#edit-content",{bucket: "taobaocms"});
if(id) {
common.util.__ajax({
async: false,
url: "/webShare/selectWebShare",
data: {id: id}
}, function (res) {
module = res.data;
},true);
}
$("#edit-content").html(common.util.__template2($("#edit-template").html(), module));
edit.init();
edit.on("file_onComplete", function (obj) {
module[obj.field] = obj.data;
});
if(id) {
$("#choose-status").show();
new common.dropDown({el: "#status"});
}
//监听数据变化
$(document).on("change", ".observe", function () {
module[$(this).data("field")] = $(this).val();
});
//保存数据
$(document).on("click", "#save_btn", function () {
if(edit.validate()) {
common.util.__ajax({
url: url,
data: module
}, function () {
setTimeout(function () {
location.href = "/operations/webshare/index";
},600);
});
}
});