I thought about that, but it's illogical and unexpected IMO.
On Mon, Nov 3, 2008 at 2:07 PM, Danny <[EMAIL PROTECTED]> wrote:
>
> It doesn't need to wait for Sizzle; you could extend jQuery.expr quite
> easily (copying most of the code from Balazs Endresz above) :
>
> jQuery.expr[':'].data = function (a,i,m){
> var re = /([\w-]+)\s*((\S{0,1}=)\s*(.+))?/; // simplified regular
> expression; should allow for escaped characters etc.
> var match = re.exec(m[3]), result = $.data(a, match[1]), value =
> result + "", type = match[3], check = match[4];
> return result === undefined ? false :
> !type ? true :
> type === "=" ? value === check :
> type === "*=" || type === "~=" ? value.indexOf(check) >= 0 :
> type === "!=" ? value != check :
> type === "^=" ? value.indexOf(check) === 0 :
> type === "$=" ? value.substr(value.length - check.length) ===
> check :
> type === "|=" ? value === check || value.substr(0, check.length
> + 1) === check + "-" :
> false;
> }
>
> and do $(":data(foo)") to select for data.foo existing, $
> (":data(foo=bar)") for data.foo == "bar", etc.
>
> Danny (a different Danny than the one who started the thread!)
>
> On Nov 3, 7:34 am, "Jörn Zaefferer" <[EMAIL PROTECTED]>
> wrote:
>> Right Ariel, I sort of stopped reading after $('*:data(foo)').
>>
>> You're right that it makes sense to aim this at Sizzle directly. I
>> think it will be quite interesting for other libraries as well to see
>> how extensible it is.
>>
>> Jörn
>>
>> On Sun, Nov 2, 2008 at 10:13 PM, Ariel Flesler <[EMAIL PROTECTED]> wrote:
>>
>> > Seems fine to me. The ideal place for it would be inside $.expr[':']
>> > but I'm not sure it fits.
>>
>> > $('*:data(foo)')
>>
>> > No place for the value. The other option (requires modifying/
>> > overloading the core) would be:
>>
>> > $('*[:foo=bar]')
>>
>> > Where those ':' are some random character that identifies this. As a
>> > generic solution, I think we could add another $.expr for characters
>> > on this place.
>> > So.. one could do (f.e)
>>
>> > $('*[~padding=0px]')
>>
>> > As a random way of selecting by style properties. Hopefully Sizzle
>> > will allow this easily.
>>
>> > --
>> > Ariel Flesler
>> >http://flesler.blogspot.com/
>>
>> > On Nov 2, 3:28 am, Danny <[EMAIL PROTECTED]> wrote:
>> >> I was recently having a discussion with a fellow developer who was
>> >> writing code that set custom html attributes to various nodes to save
>> >> information that'd be required later when working with them.
>> >> I asked him why he wasn't using jquery's built-in support, Data for
>> >> storing that information in the nodes. He responded saying, he
>> >> woulnd't be able to use jquery's selectors to query against the dom.
>> >> $("div[custId=5]") //etc.
>>
>> >> That made me wonder, why isn't there some sort of support for querying
>> >> the values in the jquery.data from within a selector. I'm aware I
>> >> could write a whole .filter(...) function but thats extrodinarily
>> >> wordy and defeat the purpose.
>>
>> >> I was wondering what others thought of this, and how useful the data
>> >> functionality is to them in this regard.
> >
>
--
Ariel Flesler
http://flesler.blogspot.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"jQuery Development" 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/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---