mirror of
https://github.com/HackPlan/RootPanel.git
synced 2026-04-23 19:21:04 +08:00
fix bugs
This commit is contained in:
@@ -1,5 +1,18 @@
|
||||
$ ->
|
||||
$.fn.checkAndRequest = (url, callback, opts) ->
|
||||
window.pageErrorHandle =
|
||||
addError: (error) ->
|
||||
$('#page-alert').append error
|
||||
|
||||
clearError: ->
|
||||
$('#page-alert').find('button').nextAll().remove()
|
||||
|
||||
showError: ->
|
||||
$('#page-alert').show()
|
||||
|
||||
hideError: ->
|
||||
$('#page-alert').hide()
|
||||
|
||||
$.fn.checkAndRequest = (url, opts, callback, errorHandle) ->
|
||||
defaults = {}
|
||||
|
||||
opts = $.extend defaults, opts
|
||||
@@ -41,4 +54,5 @@ $ ->
|
||||
url: url
|
||||
method: 'post'
|
||||
data: data
|
||||
success: callback
|
||||
success: callback
|
||||
error: errorHandle
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
$ ->
|
||||
$('.signup-form').find('button').on 'click', (e) ->
|
||||
e.preventDefault()
|
||||
$('.signup-form').checkAndRequest '/user/signup',(reply)->
|
||||
console.log reply
|
||||
,
|
||||
$('.signup-form').checkAndRequest '/user/signup/',
|
||||
username:
|
||||
check: /^[0-9a-z_]+$/
|
||||
error: '用户名必须以数字或小写字母开头'
|
||||
@@ -14,3 +12,11 @@ $ ->
|
||||
check: ->
|
||||
$('#passwd').val() is $('#passwd2').val()
|
||||
error: '两次密码不一致'
|
||||
, (reply) ->
|
||||
location.href = '/'
|
||||
, (reply) ->
|
||||
if reply.status is 400
|
||||
error = reply.responseJSON.error
|
||||
pageErrorHandle.addError error
|
||||
pageErrorHandle.clearError()
|
||||
pageErrorHandle.showError()
|
||||
|
||||
Reference in New Issue
Block a user