1

我一直在研究 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();
      }
    });
});
4

0 回答 0