On Jan 13, 2013, at 12:03 PM, tab1ta wrote:
> Hello, i'm trying to interface two different scripts, one from this mailing list and one from here.
>
> The result is a django template:Here
>
>
http://pastebin.com/LWJbUZ9v
>
> The problem is that the link:
>
> <a href="#"></a>
>
> should show a pop up windows, when clicked
>
> $('content').on('click', 'a', function openDialog() {
>
> but it simply searches for # and it doesn't show anything.
>
> Is something wrong in the code i posted?
Yup. There's two ways to fix it. First, if you're going to use openDialog elsewhere in the same script scope, then define it first and then call it directly:
var openDialog = function(){
alert('Howdy!');
};
$('content').on('click','a', openDialog());
If however it is a throw-away, one time thing, you can define an anonymous function inside your on() handler and use it directly there. You cannot just throw the function keyword in there and get anything but an error, though.
$('content').on('click', 'a', function(){ alert('Howdy!'); });
Walter
> If the problem is somewhere else i can inspect, but i'm not sure of the line of code i posted,
> Any suggestion?
>
> Thanks Agnese
>
> --
> You received this message because you are subscribed to the Google Groups "Prototype &
script.aculo.us" group.
> To view this discussion on the web visit
https://groups.google.com/d/msg/prototype-scriptaculous/-/g89TB9F28vwJ.
> To post to this group, send email to
prototype-s...@googlegroups.com.
> To unsubscribe from this group, send email to
prototype-scripta...@googlegroups.com.
> For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en.