templetEdit.js 1.36 KB
'use strict';
var $ = require('jquery'),
    common = require('../../../common/common');

require('../../../common/umeditor.config');
require('../../../common/umeditor');
require('../../../common/zh-cn');
var edit = require('../../../common/edit');


var UMdescriptioner = UM.getEditor('templet');
UMdescriptioner.setContent($("#searchTemplet").val());


var mainData = window.ViewModel;
console.log(mainData);
var e = new edit("#basicForm", {bucket: "goodsimg"});
e.on("validate", function () {    
    if ($.trim($('#caption').val()) === ''){
        return "名称不能为空";
    }
    if ($.trim(UMdescriptioner.getContent()) === ''){
        return "内容不能为空";
    }
    return true;
});
e.init();

$(document).on('click','#save_templet',function () {
    e.submit($("#basicForm").attr("action"), function (option) {        
        option.data.templet = UMdescriptioner.getContent();
        
        option.success = function (res) {
            if (res.code == "200") {
                e.$tip("提交成功", function () {
                    location.href = "/search/templetIndex"
                }, 'growl-success');
            } else {
                e.$tip(res.message);
            }
            return false;
        };
        option.error = function (res) {
            e.$tip(res.message);
        };
        console.log(option.data);
    });
    return false;
});