-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
修改demo相关的文件的名称,将来可能还会添加新的demo页面,用index.html不太好
- Loading branch information
felix
committed
May 8, 2016
1 parent
e1ad9b9
commit 796e44a
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
}); | ||
}); | ||
}); |