使用JQuery Datepick选择发布表单 [英] Post form on select with JQuery Datepick

查看:140
本文介绍了使用JQuery Datepick选择发布表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个日历我显示与仅某些日期可用和禁用的其余部分。我收到我所有的日期,并填写我的日历,它显示没有问题

 < script type =text / javascript> ; 
$(function(){
$ .post('/ jreqlib',
{Action:'GetDates',
},function(data){

var myNewDates = new Array;
for(var x = 0; x< data ['validPubDates']。length; x ++){
myNewDates.push(data ['validPubDates'] [ x $);
}
var myValidDates = new Array;
for(var x = 0; x< data ['validPubDates']。length; x ++){
var theDate = data ['validPubDates'] [x];
myValidDates.push(theDate);
}
$('#inlineDatepicker')。datepick({
multiSelect:999,
minDate:'-14d',
maxDate:'+ 2y',
onSelect:function(dateText,inst){
// alert(Clicked );
// $( #FormId)点击()。
$(本).parent(形式)提交()。
},
onDate:getAllowed(myValidDates),
})。datepick('setDate',myNewDates);
},
JSON);
});
< / script>

当单击日期时,我想提交表单(而不是通过ajax)。我发现了一堆的职位,但他们都不似乎工作。如果我取消评论alert,那么我看到clicked消息,但是没有 $(#FormId)。 ); (是的,表单中有一个id =FormId) $(this).parent('form')。submit(); 或我找到的2或3种其他方式提交表单。



我在点击中到达那里,如果没有评论,警报会触发,如何来自表单将不会提交?



(BTW - 我没有发布getAllowed函数,因为我没有认为它是相关的,但如果需要我会) p>

TIA

解决方案

尝试给表单一个id,然后通过一个jquery id选择器:

 < form id =myFormID> 
...
$('#inlineDatepicker')。datepick({
multiSelect:999,
minDate:'-14d',
maxDate:'+ 2y ',
onSelect:function(dateText,inst){
$('#myFormID')。submit(); //< - SUBMIT LIKE THIS
},
onDate:getAllowed(myValidDates),
})。datepick('setDate',myNewDates);


I have a calendar I display with only certain dates available and the rest disabled. I get all my dates and make up my calendar and it displays without problem

<script type="text/javascript">
    $(function() {
        $.post('/jreqlib', 
            { Action: 'GetDates',
            }, function(data) {

                var myNewDates = new Array;
                for (var x = 0; x < data['validPubDates'].length; x++) {
                    myNewDates.push(data['validPubDates'][x]);
                }
                var myValidDates = new Array;
                for (var x = 0; x<data['validPubDates'].length; x++) {
                    var theDate = data['validPubDates'][x];
                    myValidDates.push(theDate);
                }               
                $('#inlineDatepicker').datepick({
                    multiSelect: 999,
                    minDate : '-14d',
                    maxDate : '+2y',                        
                    onSelect : function (dateText, inst) {
                        //alert("Clicked');
                        //$("#FormId").click();
                        $(this).parent('form').submit();
                    },
                    onDate : getAllowed(myValidDates),
                }).datepick('setDate',myNewDates);
            }, 
        'json');            
    }); 
</script>

The issue is I want to submit the form (not via ajax) when a date is clicked. I found a bunch of posts but none of them seemed to work. If I un-comment that "alert" then I see the "clicked" message but neither the $("#FormId").click(); (yes the form has a id="FormId" in it) or $(this).parent('form').submit(); or the 2 or 3 other ways I found to do the form submit.

I'm getting there on the click, the alert will fire if un-commented, how come the form won't submit?

(BTW - I didn't post the getAllowed function as I didn't think it relevant but I will if needed)

TIA

解决方案

Try giving the form an id and then calling submit via an jquery id selector:

<form id="myFormID">
...
$('#inlineDatepicker').datepick({
    multiSelect: 999,
    minDate : '-14d',
    maxDate : '+2y',                        
    onSelect : function (dateText, inst) {
        $('#myFormID').submit(); // <-- SUBMIT LIKE THIS
    },
    onDate : getAllowed(myValidDates),
}).datepick('setDate',myNewDates);

这篇关于使用JQuery Datepick选择发布表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆