• smart-table select unique兼容Edge


    ng.module('smart-table').directive('stSearch', ['stConfig', '$timeout', '$parse',
        function(stConfig, $timeout, $parse) {
            return {
                require: '^stTable',
                link: function(scope, element, attr, ctrl) {
                    var tableCtrl = ctrl;
                    var promise = null;
                    var throttle = attr.stDelay || stConfig.search.delay;
                    var event = attr.stInputEvent || stConfig.search.inputEvent;
                    var trimSearch = attr.trimSearch || stConfig.search.trimSearch;
                    //兼容Edge
                    if (element[0].localName == 'select') {
                        event = 'change';
                    }
                    attr.$observe('stSearch', function(newValue, oldValue) {
                        var input = element[0].value;
                        if (newValue !== oldValue && input) {
                            ctrl.tableState().search = {};
                            input = ng.isString(input) && trimSearch ? input.trim() : input;
                            tableCtrl.search(input, newValue);
                        }
                    });
                    //table state -> view
                    scope.$watch(function() {
                        return ctrl.tableState().search;
                    }, function(newValue, oldValue) {
                        var predicateExpression = attr.stSearch || '$';
                        if (newValue.predicateObject && $parse(predicateExpression)(newValue.predicateObject) !== element[0].value) {
                            element[0].value = $parse(predicateExpression)(newValue.predicateObject) || '';
                        }
                    }, true);
                    // view -> table state
                    element.bind(event, function(evt) {
                        evt = evt.originalEvent || evt;
                        if (promise !== null) {
                            $timeout.cancel(promise);
                        }
                        promise = $timeout(function() {
                            var input = evt.target.value;
                            input = ng.isString(input) && trimSearch ? input.trim() : input;
                            tableCtrl.search(input, attr.stSearch || '');
                            promise = null;
                        }, throttle);
                    });
                }
            };
        }
    ]);
       
  • 相关阅读:
    Alter the structure of web pages with JavaScript
    The Image Gallery Revisited
    Best Practices in JavaScript
    使用eclipse生成文档(javadoc)
    字符串截取 方法 String b=a.substring(0, a.indexOf("乘坐"));
    SQL工具-压力测试工具
    SQL工具-技术支持工具
    SQL Server设置启动存储过程
    EntityFramework
    SQL Server 数据库状态选项-用户使用
  • 原文地址:https://www.cnblogs.com/yiyangl/p/10038613.html
Copyright © 2020-2023  润新知