Hi.

Hmm... I thought designers know javascript. At least for design things like 
this... :)

Try something like this.

Give a class to the element that needs the click action. You can reference 
elements in a jquery through any valid css selection. This way you can get all 
the elements and assign the action to each of them.

<div id="user1">user1<br><span id="hide_user1"
 class="hide_link">hide</span></div>

Then put in web2py_ajax_init function:

$('.hide_link').each( function() { 
    $(this).click(  function() { 
        $(this).parent().hide(); 
    }); 
});

This code searches for all elements that have hide_link as css class. Iterates 
through each of them and executes the given function on all of them. With 
$(this) you refer to the element on which the function was called. An parent() 
will give back the parent of the element.
So this will go through all elements and assign the given, second, function to 
onclick event. The inner function will get the parent element, which is the 
div element and hide it.

Hope this helps.

regards
mmlado

On Sunday 30 August 2009 16:18:15 tititi wrote:
> Thanks Mladen for menioning the the import os, I wasn't aware of this.
>
> As for (2), I was using the original approach to try to be as
> unobtrusive as possible to JS from HTML (we're trying assign
> developers to cookie-cut each area: models for DBAs, controllers for
> Pythonists, and HTML/CSS for designers, but if the controllers should
> be manipulated then I guess there is no choice? I was trying NOT to
> manipulate the web2py_ajax.html directly, only having it including a
> JS file that will be included in it. I'm not sure what the security or
> load consequences there are which is why i'm asking for feedback.
>
> Sorry I didn't included this snippet in the web2py_ajax.html to
> illustrate my point:
>
>
> function web2py_ajax_init() {
>   {{include '../static/jquery_dynamic.js'}} // import individual lines
> that manipulate IDs and CLASSES from Views files.
> });
> <<<<<
>
> I don't directly write the web2py_ajax file but the include file. Is
> this possible?
>
> Thanks again.
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to