Adding Javascript breaks editing ability

Permalink 2 users found helpful
FINALLY got mootools /slimbox working by placing lines like :

<script type="text/javascript" src="js/mootools.js"></script>

AFTER

<?php Loader::element('header_required'); ?>

in the default theme header.php

BUT

when loading web page, the Edit Page / Add Page front end buttons/java do not work.

Any help would be appreciated.

Im loving C5 but this i sdriving me nuts :)

Frank

 
ScottC replied on at Permalink Reply
ScottC
Frank,
You need to load any javascript and have the jquery and header_required loaded js loaded afterward to ensure that the core concrete5 js files are referenced and their code isn't overwritten.

I had issues with this with a foxycart block i made for a site.

I would personally like to see jquery run in a no conflict mode with some sort of $c5 instead of the default $ or something along those lines.

I could probably sit down and do this using a find/replace looking for $( and replacing with $c5( and overriding the header_required (did a post on that to use google version).
I have glanced at jquery noconflict but I haven't had a compelling reason to really switch it over...


To me I haven't found a really compelling reason to do something in mootools that I can't do in jquery. I would like to see a few examples if you must as to why you would like to use mootools. I am not in any way shape or form trying to dissuade you from using mootools especially since jquery is built to run in no-conflict where needed...I would just love to see what I am missing and why you are looking to use mootools.

-Scott
synlag replied on at Permalink Reply
synlag
Remo replied on at Permalink Reply
Remo
I agree with Scott. I could fix this too.. It would probably take a while but shouldn't be a problem at all.

But there's not reason because as Scott said, I can do everything with jQuery I want.

There are a couple of scripts that use mootools and if you're a copy & past programmer, you probably have a problem, but beside that there's not need for anything but jQuery.

If I work with rails I use prototype, with c5 jQuery and I'm fine with that..

Looks like all the people who are willing to fix that problem don't really have problem ): Sorry!
froggie81 replied on at Permalink Reply
Hi thanks for your reply.

Ok Im on borad with jquery/C5. What I am not clear on is would i sill put the includes/jscrip referances AFTER the <?php Loader::element('header_required'); ?> and the front end wont break , or should I be able to load before the Loader and expec everything to work?

Thanks, Frank
ScottC replied on at Permalink Reply
ScottC
I load everything after the header_required since most have a dependency for jquery1.2.6 to be included and jquery is included in the header_required statement.

I usually do this from either the block controller but more and more from the blockview since different views by definition should be what changes the way the content looks.
froggie81 replied on at Permalink Reply
Hi Scott;

So If i understand, jquery is already part of the base frame work and all i should need to load after the header-Required statement is for example lightbox.js and not jquery.js stuff?

And then load the lightbox.css anywhere in the header?

Thanks, Frank
ScottC replied on at Permalink Reply
ScottC
exactly right :), i'd load the lightbox.css before the header include though instead of after, just to make sure you aren't hitting a core css value for the dashboard or toolbar. I believe everything is prepended with a ccm designation so you would almost have to try to break it regardless of where the css is included, so try both or do whichever works first, but i'd suggest above the header_required first.
froggie81 replied on at Permalink Reply
Hi Scott'
Thanks for al lyour help , while I have yo and I appreciate this is off topic .. I reded every thing as we discuss and there are no apparent conflicts .. thanks. My question is when I put initialzation code like

<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
$("a[rel^='prettyPhoto']").prettyPhoto();
});
</script>

In a content block, the editor comments out the code when i save it. Q: How can I included javascript in content block?

Thanks, Frank
ScottC replied on at Permalink Reply
ScottC
the content block uses tinymce which does mess with some javascript. I have this written in a block that uses addHeaderItem from the controller which injects a javascript file in the header that has code much like what yours does there.

There is a raw html block in beta, not sure if it is ready for prime time. This would allow you to have a gallery'd image without holding your hand in regard to html.

Otherwise to mix content and images to look like a newspaper you would almost need a totally custom new contentblock...
froggie81 replied on at Permalink Reply
Thanks, I only asked because I had a full blown mootools lightbox gallery working in a content block real nice. That was how I had started this thread.

The main different was that I did not have to initialize the page via a jscript function. What I am trying now is a C5 add-on called php-block and it seems to be rendering the page properly but It's still not exectuing .. Ill work it out and learn from this experience . Thanks again for your time and patience.

Have a good one,
Frank
Tony replied on at Permalink Reply
Tony
mootools now lets you run in a non-dollar-sign mode, which should hopefully allow people to use it in conjunction with the c5 edit-mode jquery installation.
http://mootools.net/blog/2009/06/22/the-dollar-safe-mode/...

(I do agree with them that you shouldn't run both at the same time while not in edit mode)
Benji replied on at Permalink Reply
Benji
Does anyone know the best way for integrating foxycart re: jQuery? The foxycart people say you should just use the foxycart call to jQuery (via foxycart_includes.js) and not call it elsewhere. But I hesitate to go amputating jQuery from c5 (and I'm not even sure where to find the c5 jQuery call). I can get foxy and c5 to play together as long as I call foxycart_includes.js before the c5 header_required. But I figure it's slowing down performance to have two jQuery calls, so … could anyone who's traveled these waters before give some advice?