Giter VIP home page Giter VIP logo

amazeui-areaselect's People

Contributors

czl032405 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

chadwicklee

amazeui-areaselect's Issues

for in的一个bug

我说的这个forin循环处理object的bug可能大部分时候不存在,但是一出现就会在选项中增加一个属性

具体是怎么个问题 我截图
kaq3sif h 79z aeyfj5p

一共19个元素结果输出了20个 适应某个js或者浏览器在处理object的时候给对象加了一些属性。

具体问题代码为

{
            key: "buildList",
            value: function buildList(subArea) {
                var plugin = this;
                var options = this.options;
                var $list = null;
                //查找已经存在的list
                $(".am-areaselect-list", this.$popup).not("am-tmpl").each(function (idx, ele) {
                    if ($(ele).data('subArea') == subArea) {
                        $list = $(ele);
                    }
                });
                //构建list
                if (!$list) {
                    $list = $(".am-areaselect-list.am-tmpl", this.$popup).clone().removeClass("am-tmpl am-hide").data('subArea', subArea);
                    $list.appendTo($(".am-areaselect-lists", this.$popup));
                    for (var i in subArea) {
                        var $item = $(".am-areaselect-item.am-tmpl", $list).clone().removeClass("am-tmpl am-hide").text(subArea[i][options.areaNameKey]).data('value', subArea[i][options.areaValueKey]);
                        $item.appendTo($list);
                        (function (_i) {
                            $item.on("click", function (e) {
                                e.preventDefault();
                                if ($(this).hasClass("am-btn-primary") || $(this).siblings().hasClass("am-btn-primary")) {
                                    plugin.selectedArea.pop();
                                }
                                $(this).addClass("am-btn-primary").siblings().removeClass("am-btn-primary");
                                plugin.select(subArea[_i]);
                            });
                        })(i);
                    }
                }
                $list.siblings(".am-areaselect-list").addClass("am-hide");
            }
        }

将for in 改成$.map就可以很好的解决这个问题,但是这又引入了jquery依赖,我不知道是否有更好的不依赖jquery的方式,所以没有提交pr。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.