lightest non-modal dialog with jQuery?

2019-05-12 17:35发布

Here is a demo:

http://jqueryui.com/demos/dialog/

But it's too huge for me.

There are 2 thousand lines included in all.

I'd like to have one in a single file with less than 1 thousand lines.

标签: jquery dialog
5条回答
Anthone
2楼-- · 2019-05-12 18:16

I like jqmodal. (it's not necessarily modal!)
It's about 3k.

jqmodal link

Init

$('#dialog').jqm(); 

Show

$('#dialog').jqmShow();
查看更多
放我归山
3楼-- · 2019-05-12 18:20

If you have an aversion to the complexity implied by a high line-count, you need to get over this or you'll end up doing voodoo, reimplementing from scratch for lack of trust, and choosing slightly-less-complex-looking but ultimately inferior libraries.

I say this because you ask for fewer lines of code, which is a good metric for complexity and maintainability, but a poor metric for important things like good design and good docs. Even size is seldom an issue, if you use minified code.

Take a deep breath and just include the file :)

查看更多
Deceive 欺骗
4楼-- · 2019-05-12 18:32

You can strip JQueryUI to its bare essentials by unchecking all of the things you don't need from the download when you get it at http://jqueryui.com/download.

I would imagine that you can get it below 1000 lines if you do this.

查看更多
Explosion°爆炸
5楼-- · 2019-05-12 18:33

@Shore: To implement this,

HTML code:

<a id="clickme">Open Dialog</a>

<div id="dialog" style="display:none;">Hello this is a dialog</div>

JS code:

$(document).ready(function(){
    // Default settings for dialog
    $("#dialog").dialog({
        bgiframe: true,
        height: 300,
        width: 350,
        autoOpen: false,
        modal: true,
        overlay: { 
            opacity: 0.7,
            background: "black"
        }
    });
   $('#clickme').click(function(){
      $("#dialog").dialog('open');
   }); 
});
查看更多
地球回转人心会变
6楼-- · 2019-05-12 18:36

I was asking myself the same question. Where can I find a lightweight overlay plugin without including jQuery UI? After I aproximately spend an hour searching the web I decided to implement it on my own.

So after three years the answer is:
You might try jquery.mloverlay a simple, lightweight jQuery plugin for showing modal less overlays.

查看更多
登录 后发表回答