What is the difference between putting Javascript inside a js directory and inside the auto.js file in the main block directory?

Permalink
I am confused on this point and would appreciate some clarification.

It would seem that C5 pulls in any javascript files placed in a js sub-directory inside the main block directory, automatically.

But it also uses any javascript inside the auto.js file inside the main block directory too.

If I want to use Javascript inside my add.php or edit.php files should I place it inside the auto.js file, inside a js directory, or can I do both?

Which approach is better and why? If all Javascript can be placed inside the js directory is there any reason to still be using auto.js?

Carlos

 
SkyBlueSofa replied on at Permalink Reply
SkyBlueSofa
It is my understanding that the auto.js file is automatically loaded in the add.php and edit.php files. You would use external javascript files for other *.php files, such as view.php.
carlos123 replied on at Permalink Reply
Hmmm...that makes sense SkyBlueSofa though it would have been less confusing if auto.js had gone into the js directory too and would have gotten pulled in from there also.

I mean C5 is a great piece of work but trying to understand what gets pulled in from where and under what circumstances is like trying to unravel a huge pile of spaghetti with pieces weaving into and out of each other all over the place.

Anybody know where this little bit of "magic" is well documented? I mean the bit about pulling in from auto.js for add.php and edit.php but from the js sub-directory otherwise?

Thanks again for your input SkyBlueSofa.

Carlos
SkyBlueSofa replied on at Permalink Reply
SkyBlueSofa
Here's a doc on creating a new block:
http://www.concrete5.org/documentation/developers/blocks/understand...

You might be able to find some info at:
http://www.concrete5.org/documentation/how-tos/...

As for who knows...who knows? I've been working with the framework for some time now and still get buggered up sometimes.
carlos123 replied on at Permalink Reply
Thanks for your input again SkyBlueSofa!

Yeah...I've read through the first linked one you gave who knows how many times. It's...well...good as an introductory type documentation but sorely lacking in extensive examples, insight into how to do things properly when building blocks and having to decide things like where to put javascript and external css files, and otherwise.

The example block used in that documentation is...well...so simple as to be practically worthless for my purposes. It didn't really teach me much at all.

Mostly I've learned what I have looking at other people's blocks and studying their code and asking questions here (in so far as a block's code is understandable mind you...the first one I tried that on was near impossible to understand...the AutoNav block).

I am definitely going to look at some of the links at the second place you linked to SkyBlueSofa. Especially the Ajax tutorial block and some others.

I've seen that page before but it seems to change from time to time (not to mention that my knowledge has increased to allow me to better understand some of it LOL).

I just wish there was some resource that really went into the meat of how to develop with Concrete5 from a programmer/web developer's point of view. What does what where in the Concrete5 core code.

Trying to read through the core code to make heads or tails of what it does is rather a pain in the butt but it's the only option it would seem when documentation of the kind you linked to falls short.

Carlos
carlos123 replied on at Permalink Reply
To complicate things even more :)...

I just read on a page over the internet that C5 automatically includes Javascript from within a view.js file in a block's root directory too.

Is that right??

So we have auto.js being included when edit.php or add.php are called, javascript inside the js sub-directory being included for view.php, and view.js being included for...hmmm...not sure.

I read that "view.js gets included before the js directory" so plugin initialization code still has to go at the bottom of the view.php file I guess since the js library inside the js directory won't be loaded before any initialization code inside view.js.

Which leaves me wondering what exactly view.js is used for?

Anybody care to share some of their C5 wisdom on this with me to help explain what view.js is, or should be, used for?

Thanks.

Carlos
carlos123 replied on at Permalink Reply
I finally found mention of some of this in some decent documentation. Right here :).

Seehttp://www.concrete5.org/documentation/developers/blocks/directory-...

Carlos