locked
How do I prevent ajax call from puttinng two datapicker input boxes in the view? RRS feed

  • Question

  • User-1757935082 posted

    Hi, I have I’m doing an <st1:city w:st="on"><st1:place w:st="on">ajax</st1:place></st1:city> call and the retured data is in a div container. The call is made when the user selects a date from the datepicker.  When the data is returned it I have two datapacekers’s input box on the form.  I only want one on the form.  How do I prevent <st1:city w:st="on"><st1:place w:st="on">ajax</st1:place></st1:city> call from puttinng two datapicker input boxes in the view?

     

    Here’s the script which I’ve tried putting to the top and bottom of the form.

     

    <script type="text/javascript">

        $(document).ready(function () {

            $("#datep").datepicker({ showOn: "both", buttonText: "Select Date", changeMonth: true, changeYear: true, yearRange: "-2:+2", showOtherMonths: true, onSelect: function (date, datepickder) {

                var sltdDate = { selectedDate: date };

                $.ajax({

                    type: "GET",

                    url: "/Schedule/GetSchedule",

                    data: sltdDate,

     

                    datatype: "html",

                    success: function (data) {

                        $("#returnedData").html(data);

     

                    }

                });

     

            }

     

     

     

     

            });

     

        });

    </script>

     

     

     

     

     

     

     

    <div id="returnedData">

     

    @if (Model.Assignments != null)

    {

            //table header here

     

        @foreach (var item in Model.Assignments.Select((x, i) => new { Data = x, Index = i }))

    {

     

      

           // @Html.DisplayFor(modelItem => item.Data)

    //More item data here

       

    }

     

    </table>

        

    }

     

    </div>

     

     <div class ="ui-widget" >

    <label for ="datep">Date: </label><input id="datep" />

    </div>

     

       

     

     

     

    Sunday, June 1, 2014 8:03 PM

Answers

  • User-1757935082 posted

    I solved it by adding ...

      $("#returnedData #dateContainer").remove();

    ...to the success funciton.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, June 2, 2014 10:52 AM