Skip to content

Commit

Permalink
修改demo相关的文件的名称,将来可能还会添加新的demo页面,用index.html不太好
Browse files Browse the repository at this point in the history
  • Loading branch information
felix committed May 8, 2016
1 parent e1ad9b9 commit 796e44a
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions form/dist/js/app/demo1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
define(function (require, exports, module) {

//引入依赖的组件
var $ = require('jquery'),
bootstrap = require('lib/bootstrap'),
Form = require('mod/formMap'),
Url = require('mod/url'),
Ajax = require('mod/ajax');

//定义常量及组件初始化
var API = {
save: '/api/user/save'
},
BUTTONS = {
SAVE: $('#btn-save')
},
appForm = new Form('#appForm', {
mode: Url.getParam('mode')
});

//业务逻辑
BUTTONS.SAVE.click(function(){
BUTTONS.SAVE.button('loading');
Ajax.post(API.save,appForm.getData()).done(function(res){
if(res.code == 200) {
alert('保存成功!');
} else {
alert('保存失败!');
}
}).fail(function(){
alert('保存失败!');
}).always(function(){
BUTTONS.SAVE.button('reset');
});
});
});

0 comments on commit 796e44a

Please sign in to comment.