首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Alertify提示-允许用户输入值和提交表单

Alertify提示-允许用户输入值和提交表单
EN

Stack Overflow用户
提问于 2015-08-03 14:07:31
回答 2查看 6K关注 0票数 3

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

代码语言:javascript
复制
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构建一个模式表单,用户将看到预先提供的详细信息,并可以输入他的详细信息并提交?

EN

回答 2

Stack Overflow用户

发布于 2015-09-26 14:53:00

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

从他们的网站代码如下:

代码语言:javascript
复制
<!-- 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代码:

代码语言:javascript
复制
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"]');
票数 2
EN

Stack Overflow用户

发布于 2015-09-16 18:34:35

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

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

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

票数 -2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31780423

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档