开发者

JQuery datepicker onSelect calling Url.Acion

again bit new to Jquery!

Have the following script and action. The action is being called ok but the id is always empty.

Thanks

<script type="text/javascript">
    $(function() {
        $('#datepicker').datepicker({
            dateformat: 'yy-mm-dd',
            inline: true,
            onSelect: function(date, inst) {
                $('#diary img').attr(
                    'src', 
                    '&开发者_Python百科lt;%= Url.Action("Image") %>?id=' + date.toString());
            }
        });
    });        
</script>

public ActionResult Image(string id)
{
    if (!string.IsNullOrEmpty(id))
    {
    }
}


Use .asString() instead. That's the method the author of datePicker uses. credits to: JQuery Datepicker returned Date object type


Managed to get it working by playing around a bit.

<script type="text/javascript">
    $(function() {
        $('#datepicker').datepicker({                
            inline: true,
            onSelect: function() {
            var date = $('#datepicker').datepicker('option', 'dateFormat', 'yy-mm-dd');                
            $('#diary img').attr(
                    'src',
                    '<%= Url.Action("Image") %>/' + date.val().toString());
            }                               
        });
    });        
</script>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜