David,

What you ask is exactly what the plugin does. Take a look at the blog post
explaining how you can use it to replace obtrusive javascript at:

http://redotheweb.com/2007/02/28/unobtrusive-javascript-made-possible/

François 

-----Message d'origine-----
De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] De la
part de David Duymelinck
Envoyé : jeudi 1 mars 2007 08:47
À : jQuery Discussion.
Objet : Re: [jQuery] Announce: Unobtrusive JavaScript with jQuery andsymfony

François Zaninotto schreef:
> Hi list,
>  
> I just pop in to mention a new plugin for the symfony framework
> (http://www.symfony-project.com) that uses jQuery to implement 
> unobtrusive scripting. It's still in its infancy, but it takes the 
> best of the jQuery syntax concision and provides useful tools for 
> interface developers who worry about accessibility.
>  
> The plugin description is available at:
>  
> http://www.symfony-project.com/trac/wiki/sfUJSPlugin
>  
I took a look at the demo's on the plugin page and the first thing i noticed
was the use of the onclick event. My idea of unobtrusive scripting is to
strip as much javascript as possible out of the html code.

wouldn't it be possible to do something like this

<html>
<head>
<title>test</title>
<?php UJS_Placeholder(); ?>
</head>
<body>
<div id="foobar"click me</div>

<?php UJS_add_behaviour('#foobar', 'click', "alert('foobar')") ?> </body>
</html>

and render it like this

<html>
<head>
<title>test</title>
<script type="javascript">
$(function(){

$('#foobar').click(function() { alert('foobar') });


});
</script>
<body>
<div id="foobar"click me</div>

</body>
</html>

i'm just thinking aloud. It could also be good to cache the javascript like
this <?php UJS_Placeholder('/js/testpage.js'); ?>

Anyway nice work. I feels good to see jquery hooked into php, before we know
it will be the prototype library of php :)

--
David Duymelinck
________________
[EMAIL PROTECTED]


_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to