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
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>
<%} %>
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>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
There are no li elements on the page.
I have closed the input tag but this has made no difference
I have closed the input tag but this has made no difference
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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>
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.
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 ?