получение переменной с текстом в failure
Имеется код:
Ext.require([ 'Ext.form.*' ]); var win; Ext.onReady(function() { Ext.apply(Ext.form.VTypes, { password: function(val, field) { if (field.initialPassField) { var pwd = field.up('form').down('#' + field.initialPassField); return (val == pwd.getValue()); } return true; }, passwordText: 'Passwords do not match' }); if(!win){ var form = new Ext.form.FormPanel({ layoutConfig: { itemCls: 'x-abs-layout-item', }, baseCls: 'x-plain', defaultType: 'textfield', fieldDefaults: { msgTarget: 'side' }, url: '<%=users_path%>', items: [{ fieldLabel: 'Логин:', name: 'login' },{ fieldLabel: 'Email:', vtype: 'email', name: 'email' },{ fieldLabel: 'Password', name: 'pass', id: 'pass', inputType: 'password' },{ fieldLabel: 'Confirm Password', name: 'passcfrm', inputType: 'password', vtype: 'password', initialPassField: 'pass' }], waitMsgTarget: true, buttons: [{ text: 'Зарегистрироваться', handler: function(){ var form = this.up('form').getForm(); if (form.isValid()) { form.submit({ waitMsg: 'Загрузка...', success: function(){ win.hide(); Ext.Msg.show({ title: 'Поздравляем!', msg: 'Вы успешно зарегистрировались в системе', buttons: Ext.Msg.OK, animEl: 'elId', icon: Ext.window.MessageBoxWindow.QUESTION, }) }, failure: function() { Ext.Msg.alert('Ошибка', 'Выбранный вами Email / Логин уже заняты') } }) } } },{ text: 'Отмена', handler: function(){ win.hide(); } }] }) } win = Ext.create('Ext.window.Window', { title: 'Регистрация', closeAction: 'hide', bodypadding: 10, width: 300, bodyStyle: 'padding: 10px; background-color: #D0DEF0;', height: 220, minHeight: 220, minWidth: 300, layout: 'fit', resizable: true, animCollapse: true, collapsible: true, constrain: true, modal: true, items: [form] }) win.show() }) и контроллер: def create @users = {'password' => params[:pass], 'password_confirmation' => params[:passcfrm], 'login' => params[:login], 'email' => params[:email]} user = User.new(@users) if user.save render :text => true elsif render :text => false end end что именно надо передавать из контроллера, помимо true / false ? что бы вместо failure: function() { Ext.Msg.alert('Ошибка', 'Выбранный вами Email / Логин уже заняты') } выводить из переменной свою ошибку ? |
success: function (response, request) { var responseObj = Ext.decode(response.responseText); if (responseObj.success == true) { } else { request.failure(response); } }, failure: function(response) { var responseObj = Ext.decode(response.responseText); } |
Часовой пояс GMT +3, время: 20:16. |