Truppe Steven schrieb:
> Hello,
> 
> i have some javascript that i execute inside a $(document).ready to init
> stuff need to be done if javascript is available. now i want to
> pass parameters somehow. My first thought was just to use an standart
> attribute like <a href=".." class="isearchforthis" lang="myparams">.
> 
> But this seems to be no good solution because i want my documents do be
> valid xhtml strict ...
> 
> So my new approach is to use a pseudo class to like <a href=".."
> class="doStuff mode1"> for example.
> So the "mode1" class is just a pseudo class that i used to determine
> which mode to use.
> 
> The code look like this:
> /$(window).load(function() {
>     $(".doStuff").each(function(){
> 
>         var cl = $(this).attr('class');
>         if(cl.test('paramMode1')) {
> 
>         }else if(cl.test('paramMode2')) {
> 
>         }else { // default mode
> 
>         }
>     });
> });
> 
> 
> /If i want to specifie more than just a mode parameter are there any
> other ways to pass parameters
> to my function that does not break xhtml validation ?/
> 
> /best regards,
> Truppe Steven


Hi Truppe,

first of all, I wouldn't even call it a pseudo class, because the class 
attribute is not only intended for styling purposes:

"The class attribute has several roles in HTML:
     * As a style sheet selector (when an author wishes to assign style 
information to a set of elements).
     * For general purpose processing by user agents."
http://www.w3.org/TR/html401/struct/global.html#h-7.5.2

So you may feel comfortable with the solution you took.

Now to your question: What about sticking to the one additional class 
and using a hash map to gather other parameters from that with the class 
  as key...:

{
     mode1: [param1, param2, param3],
     mode2: [param1, param2, param3]
}

Something like this. Of course there is an overhead of creating and 
maintaining this hash map and including it in the page but you could 
even load it via XHR as JSON...

-- Klaus


_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to