使用alertify - version 0.3.11,我可以获取用户输入的详细信息,并可以在提示对话框中显示它。但是我有多个值(value)观。用户输入,下拉值,日期选择等

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");
    }
});

类似于下图所示

javascript - Alertify提示-允许用户输入值并提交表单-LMLPHP

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

最佳答案

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

从他们的网站代码如下:

<!-- 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"]');

关于javascript - Alertify提示-允许用户输入值并提交表单,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/31780423/

10-09 22:42