Beispiel #1
0
 CartList.prototype.initBehavior = function() {
     var util = require('er/util');
     this.view.on('plus', util.bind(plusBook, this));
     this.view.on('minus', util.bind(minusBook, this));
     this.view.on('remove', util.bind(removeBook, this));
     this.view.on('clear', util.bind(clearCart, this));
 };
Beispiel #2
0
        BookListView.prototype.enterDocument = function() {
            var container = $('#' + this.container);

            var util = require('er/util');
            $('#book-list').on('click', '.buy', util.bind(buyBook, this));
            $('#submit-search').on('click', util.bind(search, this));
            $('#list-page').on(
                'click', ':not(.disable)' , util.bind(flip, this));

            container.on(
                'click',
                '.name',
                function(e) {
                    // e.preventDefault();
                    // return;
                    var url = $(this).attr('href').substring(1);
                    var controller = require('er/controller');

                    this.loadingBookViewAction = 
                        controller.renderChildAction(url, 'book-info-panel');
                    this.loadingBookViewAction.done(showBookInfo);
                    return false; // 这里阻止了 链接的默认跳转行为。只是打开了一个子anction
                }
            );
        };
Beispiel #3
0
        /**
         * 给指定的控件绑定事件
         *
         * @param {UIView} view View对象实例
         * @param {string} id 控件的id
         * @param {string} eventName 事件名称
         * @param {function | string} handler 事件处理函数,或者对应的方法名
         * @return {function} 绑定到控件上的事件处理函数,不等于`handler`参数
         * @inner
         */
        function bindEventToControl(view, id, eventName, handler) {
            if (typeof handler === 'string') {
                handler = view[handler];
            }

            if (typeof handler !== 'function') {
                return handler;
            }

            handler = util.bind(handler, view);
            var control = view.get(id);
            if (control) {
                control.on(eventName, handler);
            }

            return handler;
        }
Beispiel #4
0
 BookList.prototype.initBehavior = function() {
     var util = require('er/util');
     console.log('initBehavior');
     this.view.on('buy', util.bind(buyBook, this));
     this.view.on('search', util.bind(search, this));
 };
Beispiel #5
0
 expect(function() { util.bind(function(){}) }).not.toThrow();