Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am trying to attempt to call back a value from a function, however, the call back is always undefined because the jQuery Date Picker never has a chance to set the var sdate, thus alerts me that it is undefined. I realy need your help and can't seem to get passed this problem.

var sdate
function test() {


    select_date()
    alert(sdate)

    }


  function select_date() {

    $('#dd').dialog({
        autoOpen: true,
        modal: true,
        overlay: {
            opacity: 0.5,
            background: 'black'
        },
        title: "title",
        height: 265,
        width: 235,
        draggable: false,
        resizable: false

    }); //end of dialog

    var x
    $('#d1').datepicker({
        onSelect: function() {
            sdate = $(this).val();
            $("#dd").dialog("close");
        }
    });
    return sdate

}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
123 views
Welcome To Ask or Share your Answers For Others

1 Answer

What does this do for you?

$('#d1').datepicker({
        onSelect: function() {
           sdate = $(this).val(); 
          //set value to the global variable (although not the best approach)
            $("#dd").dialog("close");
        }
 });

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...