小编Tom*_*Tom的帖子

Backbone.js和表单输入模糊

我几乎是新手的骨干.我正在向mysql提交表单数据.

我有一个特殊的输入框,其中使用他或她的电子邮件地址中的类型作为用户名.就目前而言,我可以检查所有输入字段(用户,通行证,地址,电话等)客户端,使用按钮上的事件,加载模型,使用PHP将数据放入数据库.这很好用,并经过测试.后端验证工作正常,并在必要时提供给浏览器.

现在我想在写入记录之前检查后端的loginname字段(我知道我可以在最后的提交中将其记录在后端但是想在这里进行).如果用户已经拥有一个具有相同电子邮件地址的帐户,我想抓住该客户端.问题是当我离开loginname字段时,我似乎无法找到捕获这种模糊(或onblur或改变我使用的任何东西)的方法,所以我可以(在视图的渲染中我可以想到的全部)去掉,再次使用PHP并发回"新"或"现有"标志

Google开发者工具中没有错误

    define([
   'jquery',
   'underscore',
   'backbone',
   'lib/jquery-migrate-1.2.1',
   'models/RegisterModel',
   'text!templates/RegisterTemplate.html',
   'lib/jquery.maskedinput-1.0',
   'lib/bootstrap-acknowledgeinput.min',
   'lib/jqBootstrapValidation'
    ], function($, _, Backbone, jQueryMigrate, RegisterModel, RegisterTemplate,   
        MaskedInput,Ack, jqAck){

   var RegisterView = Backbone.View.extend({

    el: $("#container"),
    events: {
          'click .btn-primary': 'saveClient',
          'focusout .loginname': 'usercheck'
       },

     usercheck: function() {     //** not working
         console.log("usercheck detected");
         alert("Alerts suck.");
         },

     render: function(){

    //Since our template has dynamic variables in it, we need to compile it
    var compiledTemplate = _.template( RegisterTemplate, this.model );
    this.$el.html(compiledTemplate); //Replaces EVERYTHING inside the <div 
                                           id="container">
    this.$('#phone').mask('(999) 999-9999'); …
Run Code Online (Sandbox Code Playgroud)

forms events textbox blur backbone.js

2
推荐指数
1
解决办法
1万
查看次数

标签 统计

backbone.js ×1

blur ×1

events ×1

forms ×1

textbox ×1