Backbone - TypeError:搜索未定义

时间:2013-02-21 22:52:11

标签: javascript backbone.js requirejs

我一直在研究Backbone.js问题。完全免责声明 - 我对javascript和Backbone都很新鲜,所以原谅我糟糕的术语。我的文件city_search.js是模态的骨干视图。最近,我在我的主页上添加了一些更改,它加载city_search.js并且我在页面加载时不断收到以下错误。

TypeError: search is undefined指向return search.extend行。

为什么搜索未定义?它没有引用我的common/views/search文件吗?

define([
    "jquery",
    "require",
    "common/views/search",
    "common/views/view"], function ($, require, search, view) {
    return search.extend({
        placeHolder: "Find city",
        render: function () {
            search.prototype.render.call(this);
            this.$el.find("input").attr('name', 'city');
        },
        selectItem: function (item) {
            this.$el.find("input").val(item.get("name"));
            $("input[name='city_id']").val(item.get("id"));
            this.closeList();
        }
    });
});

search.js

/**
 * Definition of a search module
 **/
define([
    "jquery",
    "underscore",
    "common/views/view",
    "text!common/views/search.jst",
    "text!common/views/search_list.jst",
    "haway/views/add_place",
    "haway/views/window_matcher", //this was recently added
], function($, _, view, template, listTemplate, add, win) {
    return view.extend({

      //A lot of irrelevant code removed

      /**
      * Selects add new place
      **/

      addNewPlace: function(e) {
        console.log("addNewPlace triggered");
        this.closeList();
        this.win = new win();
        this.win.render();
      }
    });
});

0 个答案:

没有答案