Link to home
Start Free TrialLog in
Avatar of ToString1
ToString1

asked on

jquery datapicker not working in MVC view

Why doesnt a jquery datapicker not work in an MVC view when I am looping through a set of records?

In my view I render out a list (code snippet below).

If I comment this code out then the date picker works but if I leave the code below in the date picker does not work, no error just no date picker


<% foreach (myModel.Models.Idea item in Model.ListOfStuff)
           {  %>
        <li>
            <%= Html.ActionLink(item.Title, "Details", new { id = item.Id })%>
            -
            <%= Html.ActionLink("Details","Details",new {id=item.Id}) %>
            |
            <%= Html.ActionLink("Edit", "Edit", new { id = item.Id })%></li>
        <%} %>

Open in new window

Avatar of Roman Gherman
Roman Gherman
Flag of Moldova, Republic of image

Hmmm,
It is not clear where the datepicker is created and for what element, can you please provide more code where datepicker is created, on which elements, where the code above is positioned ?
Avatar of ToString1
ToString1

ASKER

Looking at source of rendered view..I have copied code below
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>

    <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>

    





    <script type="text/javascript">
        $(document).ready(function() {
            $("#datepicker").datepicker();
        });
    </script>


</head>

then in the body 


  <div class="aList">
        Date :
        <input type="text" id="datepicker" name="datepicker">
    </div>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Roman Gherman
Roman Gherman
Flag of Moldova, Republic of image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
There are no li elements on the page.

I have closed the input tag but this has made no difference
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Whoops sorry about that!

Here is the markup and I have replaced the text


    <p>
        test</p>
    <ul class="test">
       
        <li>test tes test <br/>
        </li>
       
    </ul>
    <h2>
        Search</h2>
    <p>
        Test test </p>
    <div class="search">
        Date :
        <input type="text" id="datepicker" name="datepicker" />
    </div>
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I reckon it maybe to do with nested master pages.   However it does seem strange that to iterate through and created an unordered list results in the date picker not working.