Re: [jQuery] OT: technique to pass values to JS/JQuery through HTML

2006-09-11 Thread Paul Bakaus
Hi there,another interesting feature I use very often is to extend the XHTML namespace and just use custom attributes like isDisabled, isEditable and such stuff.At any rate, your browser will ignore these attributes and you will have access to them via getAttribute, if you want a validating xhtml file, you should also add a custom dtd file. Check this out: 
http://www.w3.org/TR/xhtml-modularization/dtd_developing.htmlHope this helps!2006/9/10, Arash Yalpani 
[EMAIL PROTECTED]:Hi Klaus,thanks for your answer and your hint to w3! So it seems to be a common
technique. I was wondering if I am the only one doing this, but it'sgood to know that I have accomplices out there ;-)Cheers, ArashKlaus Hartl schrieb:Arash, you could as an alternative use the class attribute for that, but
theres no need to feel false about the id as well. From the HTML Spec:The id attribute has several roles in HTML: * As a style sheet selector. * As a target anchor for hypertext links.
 * As a means to reference a particular element from a script. * As the name of a declared OBJECT element. * For general purpose processing by user agents (e.g. foridentifying fields when extracting data from HTML pages into a database,
translating HTML documents into other formats, etc.).The class attribute, on the other hand, assigns one or more class namesto an element; the element may be said to belong to these classes. A
class name may be shared by several element instances. The classattribute has several roles in HTML: * As a style sheet selector (when an author wishes to assign styleinformation to a set of elements).
 * For general purpose processing by user agents.http://www.w3.org/TR/REC-html40/struct/global.html#h-7.5.2
-- klausArash Yalpani schrieb:Hi,this has nothing to do with JQuery directly but since the brightestminds are around in this mailing list and this should be of general
interest...What I am trying to do is to pass values along with a tag, so I can usethat values on a mouse click or so. A short example:ulli id=li_123Johnny/li
li id=li_345Nina/lili id=li_54Olga/li/ulNow I could do something like this (pseudocode, might not work):
$('ulli').click(function(){var userId = $(this).attr('id').split('_')[1];$.get('doSomething.php?userId=userId');});But it's an ugly workaround, most of the times I wouldn't want to use
the id-attribute like this and I am not sure if any other HTML universalattribute can be used for this purpose. I have seen some otherimplementations of this technique for tooltips for example. Stefan uses
it for his great Interface library where he takes the title tag's valueas an input for the tooltip text. It is even semantically ok:a href="" href="http://www.yahoo.com">
http://www.yahoo.com title=Link to YahooYahoo/aMy question is: do you use similar techniques and what benefits/problemsto they bring with? What are the alternatives?
Cheers, Arash--Arash YalpaniEntwicklung browserbasierter Software-AnwendungenPrenzlauer Allee 173 | 10409 Berlin
[EMAIL PROTECTED] | http://www.yalpani.de___jQuery mailing listdiscuss@jquery.com
http://jquery.com/discuss/-- Paul BakausWeb DeveloperHildastr. 3579102 Freiburg
___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] OT: technique to pass values to JS/JQuery through HTML

2006-09-10 Thread Klaus Hartl
Arash, you could as an alternative use the class attribute for that, but 
theres no need to feel false about the id as well. From the HTML Spec:


The id attribute has several roles in HTML:

 * As a style sheet selector.
 * As a target anchor for hypertext links.
 * As a means to reference a particular element from a script.
 * As the name of a declared OBJECT element.
 * For general purpose processing by user agents (e.g. for 
identifying fields when extracting data from HTML pages into a database, 
translating HTML documents into other formats, etc.).

The class attribute, on the other hand, assigns one or more class names 
to an element; the element may be said to belong to these classes. A 
class name may be shared by several element instances. 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/REC-html40/struct/global.html#h-7.5.2


-- klaus



Arash Yalpani schrieb:
 Hi,
 
 this has nothing to do with JQuery directly but since the brightest 
 minds are around in this mailing list and this should be of general 
 interest...
 
 What I am trying to do is to pass values along with a tag, so I can use 
 that values on a mouse click or so. A short example:
 
 ul
   li id=li_123Johnny/li
   li id=li_345Nina/li
   li id=li_54Olga/li
 /ul
 
 Now I could do something like this (pseudocode, might not work):
 
 $('ulli').click(function(){
   var userId = $(this).attr('id').split('_')[1];
   $.get('doSomething.php?userId=userId');
 });
 
 But it's an ugly workaround, most of the times I wouldn't want to use 
 the id-attribute like this and I am not sure if any other HTML universal 
 attribute can be used for this purpose. I have seen some other 
 implementations of this technique for tooltips for example. Stefan uses 
 it for his great Interface library where he takes the title tag's value 
 as an input for the tooltip text. It is even semantically ok:
 
   a href=http://www.yahoo.com; title=Link to YahooYahoo/a
 
 
 My question is: do you use similar techniques and what benefits/problems 
 to they bring with? What are the alternatives?
 
 Cheers, Arash
 
 
 ___
 jQuery mailing list
 discuss@jquery.com
 http://jquery.com/discuss/
 

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