3

使用alertify - version 0.3.11,我能够获取用户输入的详细信息并能够在提示对话框中显示它。但我有多个价值观,即。用户输入、下拉值、日期选择等

var totalResources = jQuery('#grid').jqGrid('getGridParam', 'selarrrow');

//set custom button title for Form Submit
    alertify.set({ labels: {
        ok     : "Submit Data",
        cancel : "Cancel"
    } });


    //fetch user input comment
    alertify.prompt("Please enter note/remarks for this Form :<br/>Total Resource(s): <strong>"+totalResources.length+"</strong>", function (e,value) {


if (e) {
    alertify.success("Data has been submitted");

            //encodes special characters remarks
            var sow = encodeURIComponent(value);

            $.post(SITE_URL+"somecontroller/someaction",$("#frm_submit").serialize()+ "&resource_ids="+resource_ids+"&sow="+sow, function( data ) {
            });


    }else{
            alertify.error("Your Data is not submitted");
    }
});

类似于下图所示

在此处输入图像描述

我如何使用 alertify 构建一个模式表单,用户将在其中看到预先设置的详细信息并可以输入他的详细信息并提交?

4

2 回答 2

2

他们在 Alertify 中添加了表单功能。看看这个

从他们的网站代码如下: -

<!-- the form to be viewed as dialog-->
<form id="loginForm">
    <fieldset>
        <label> Username </label>
        <input type="text" value="Mohammad"/> 

        <label> Password </label>
        <input type="password" value="password"/> 

        <input type="submit" value="Login"/>
    </fieldset>
</form>

和JS代码: -

alertify.genericDialog || alertify.dialog('genericDialog',function(){
    return {
        main:function(content){
            this.setContent(content);
        },
        setup:function(){
            return {
                focus:{
                    element:function(){
                        return this.elements.body.querySelector(this.get('selector'));
                    },
                    select:true
                },
                options:{
                    basic:true,
                    maximizable:false,
                    resizable:false,
                    padding:false
                }
            };
        },
        settings:{
            selector:undefined
        }
    };
});
//force focusing password box
alertify.genericDialog ($('#loginForm')[0]).set('selector', 'input[type="password"]');
于 2015-09-26T06:52:59.673 回答
-2

这实际上超出了 Alertify 的范围。它只是不支持那种功能。它被设计为替代典型的浏览器内置功能,如confirm()alert().

您可能想查看其他插件。特别是因为您使用的是 jQuery,所以找到适合您的东西应该不会太难。搜索 jQuery 灯箱或模式可能会找到具有您正在寻找的功能的东西。

一种选择可能是Fancybox。那里有一个登录表单的演示,它做类似的事情。我从来没有用过 Fancybox,所以你的里程可能会有所不同,但那里有很多不同的选择。

于 2015-09-16T10:34:34.937 回答