views:

40

answers:

1

I am busy trying to write an Html.DatePickerFor helper, but say I want to use a custom date picker that has JavaScript dependencies, how could I expand my CustomActionLink call to, before rendering content offered by the link, ensure that e.g. jQuery and my own scripts, are on the view being rendered.

In a WebForms app, I would use RegisterClientScript, but with an action link it seems quite more complex.

A: 

Hide the link in your CSS and have a JavaScript function make the link visible. If you put the function in your $(document).ready() call, you'll be sure jQuery has been loaded (or else it won't execute and the link will remain hidden).

Jon Smock
Yes, thanks, but my point is to create a permanenly reusable tool, so that when another dev invokes `Html.DatePickerFor(..`, he doesn't need to have configured the jQuery refs etc. Otherwise I would just use a textbox and 'jQuery it up all pretty'.
ProfK