• jquery开发模板


    模板

    /**
     * @author hp
     *
     * 初始化:
     * $("#xxx").hpSelect({
                data: [{
                    id: '1',
                    name: '我的实习实践计划(项目)',
                    selected:true
                }, {
                    id: '2',
                    name: '全部'
                }],
                autotrue,
                '200',
                height:'30',
                optionBoxWidth: '200',
                callBack: function() {
                  //  alert($("#select").hpSelect("getName"));
                }
            });
     * 方法:
     * 获取ID$("#xxx").hpSelect("getId")
     * 获取name$("#xxx").hpSelect("getName")
     *
     * 设置ID$("#xxx").hpSelect("setId",data)
     * 设置多个ID$("#xxx").hpSelect("setIds",arry)
     * 设置Name$("#xxx").hpSelect("setName",name)
     * 设置Name$("#xxx").hpSelect("setData",data);异步设值,下拉内容
     *
     * @date 2017-02-08
     */
    (function($) {
        //初始化对象可设置的属性
        var defaults = {
            data: "",
            auto false,      //是否固定宽度,true 为自动宽度,false 为固定宽度
             '100',          //固定宽度时,设置select的宽度
            maxWidth: '200',       //自动宽度时候,设置最大select的宽度
            optionBoxWidth: '100', //设置下拉最大宽度
            height: "30",          //设置select高度
            placeholder:"请输入",  //输入提示语
            callBack: function() {}//回调函数
        };
        var methods = {
            init: function(options) {
                $(this).hpSelect('setOptions', options);
                return this;
            },
            /**
             * 设置运行参数
             */
            setOptions: function(options) {
                // 尝试去获取settings,如果不存在,则返回“undefined”
                var settings = $(this).data('hpSelect');
                // 如果获取settings失败,则根据options和default创建它
                if (!settings)
                    settings = {};
                settings = $.extend({}, defaults, options);
                // 保存我们新创建的settings
                $(this).data('hpSelect', settings);
                return this;
            }
    
        };
        $.fn.hpSelect = function(method) {
            //假如方法存在
            if (methods[method]) {
                return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
                //假如方法不存在,直接调用methods的init方法
            } else if (typeof method === 'object' || !method) {
                return methods.init.apply(this, arguments);
                //否则报错。方法名不正确
            } else {
                alert('错误: ' + method + ' 不是本插件的方法!');
            }
        };
    
    })(jQuery);
  • 相关阅读:
    类操作工具类
    让你的Git水平更上一层楼的10个小贴士
    android camera(四):camera 驱动 GT2005
    android camera(三):camera V4L2 FIMC
    android camera(二):摄像头工作原理、s5PV310 摄像头接口(CAMIF)
    android camera(一):camera模组CMM介绍
    MTK Android Driver知识大全
    makefile 进阶
    RGB Bayer Color分析
    8.3 MPI
  • 原文地址:https://www.cnblogs.com/hupan508/p/7463297.html
Copyright © 2020-2023  润新知