Date Nav missing Javascript when inserted with code

Permalink
If I add a Date Nav content block in an Area and configure it, everything work out ok.

However, I want to insert the block programmatically, so in the template I have:
$dateNav = BlockType::getByHandle('date_nav');
$dateNav->controller->selectCTID = 9;
$dateNav->controller->cParentID = $blogPageID;
$dateNav->controller->flatDisplay = 0;
$dateNav->controller->defaultNode = 'current_month';
$dateNav->controller->showDescriptions = 0;
$dateNav->controller->truncateTitle = 1;
$dateNav->controller->truncateTitleChars = 60;
$dateNav->render('templates/blog-date-nav');


The results returned are correct, but I get javascript errors relating to:

"ccmDateNav is not defined"

I have copied into my site-specific block templates folder the js folder, etc from the original block folder, but to no avail. It seems the date_nav.js file is not being found / referenced when adding it programmatically under a new block template.

Can someone advise?

Cheers,

Gav

GavMurphy
 
JohntheFish replied on at Permalink Reply
JohntheFish
Have a look at
http://www.concrete5.org/community/forums/usage/datepicker-inside-o...
It goes through a similar problem, but from a php block rather coding into an area.
GavMurphy replied on at Permalink Reply
GavMurphy
Thanks, John. But I can't quite see how that relates as the js being called appears to be the auto.js file that sits with the block in the folder, not an external js source such as jQueryUI, etc.

I've added the auto.js into my top level block folder with the view, etc and still no joy.

Very confused. Thanks for your fast response, sir.
JohntheFish replied on at Permalink Reply
JohntheFish
I see what you mean, the issues are not as close as I had first guessed. I was mixing date-nav with date-picker.
The file auto.js is only loaded with add/edit, not with view.
You may find 'Ajax Lessons' educational on this. Not for the ajax, but it also runs live demonstrations of different ways of including javascript and summarises which work in different contexts. On the other hand, there is a risk that it would be a confusing misdirection.