views:

50

answers:

6

I have a partial page with a jquery calendar on my form. When the partial page loads the calendar button does not show.

I am using Ajax.BeginForm and UpdateTargetId to load the partial page.

I think the Jquery does not initialize on a partial page.

Anyone know what is going on?

A: 

Not trying to be rude, but I don't believe anyone will be able to answer this question without more information. Can you post your code?

tambler
This is more of a a'how to' problem than a 'code' problem. The calendar works fine if in the main page, but fails to work on a partial page.
Joe
A: 

Are you loading the partial via AJAX? Does your partial include the jQuery code to create the calendar? If the former is true, then the latter must be true. Including the code for the calendar on the main page instead of the partial, then loading the partial via AJAX means that the calendar element doesn't exist when the code on the main page runs. The code that sets up the calendar needs to be loaded with the partial.

tvanfosson
I am using Ajax.BeginForm and UpdateTargetId.
Joe
Then run the code that sets up the calendar in the OnSuccess callback for the AJAX form.
tvanfosson
A: 

If the element is initialised in the $(document).ready() function, that could be the reason, since that funcon is not run until the entire document is loaded. Hard to say without more information about your html/js code.

kb
+1  A: 

How about use jQuery.live?

.live() – jQuery API

takepara
Where would I put this?
Joe
Write script page bottom in document.ready event. $(function(){ /* here */ }).
takepara
A: 

This is how I'm using it using livequery

I do understand that with jQuery1.4.1 the issues they were having with .live() (or at least the issues I used to have, have been resolved.

$('#txtStartDate').livequery(function(e) { $('#txtStartDate').datepicker({ dateFormat: 'dd/mm/yy' }); });

Kamal
A: 

have you tried adding a click handler to the button that initializes the calendar? not sure if this will work or not, i've never used the ajax.beginform. i prefer to wire up my ajax forms manually so i have more control over everything.

scratch that: put the intialization of the calendar in a function and pass that as the OnSuccess parameter.

see here: http://www.gbogea.com/2008/11/26/ajax-beginform-clear-form-after-submit

Patricia