I am getting closer, changing the selector from:
[class^='+options.cssprefix+'-]
to
[class*='+options.cssprefix+'-]
solved the problem of not retrieving class attribute with multiple
class name.
After I use a regex to extract each class that is related to the
plugin only:
sx-[^\s]+ ?{.*}|sx-[^\s]+
that works fine in The Regex Coach for the follwoing example:
red sx-dialog {var: 'val'} sx-draggable black
But it doesn't work (or I dont use it properly) somehow in the code:
// sx class detector regex ( sx-[^\s]+ ?{.*}|sx-[^\s]
+ )
var sx_reg = new RegExp(options.cssprefix+'-[^\\s]+ ?\{.*
\}|'+options.cssprefix+'-[^\s]+ \g');
// scriptless elements?
$('[class*='+options.cssprefix+'-]').each(function(i)
{
// class string
var clstr = $(this).attr('class');
// get all classes
var classes = sx_reg.exec(clstr);
if (classes) $.each(classes, function(i){
alert(classes[i]); });
else alert(clstr);
});
That would only return this format sx-foo {var:val} also the first
match is always this format. I need to do more reading and testing,
but it think it is the way to go. or well i will see.
On Apr 10, 4:59 pm, Ricardo <[email protected]> wrote:
> I don't have Firebug here so can't test anything and didn't bother to
> read the whole source, but from what I see you're using a simple regex
> that extracts each word in the className and then you *assume* your
> required class is the first one, right?
>
> You could try eliminating the whitespace between the main class and
> it's options, that way you know they are related and don't need to
> guess classes:
>
> <div id="greenbox" class="green sx-shake{event: 'dblclick'}
> someotherclass"></div>
>
> $('[className*="sx-shake"]').each(function(){
> //here you know it's a 'shake' element, so use a special regex to
> get the options:
> /sx\-shake\{(.*)\}/.exec( this.className) // something like that
>
> });
>
> This class-gathering process could certainly be streamlined into a
> single function.
>
> On Apr 9, 10:05 am, Gilles <[email protected]> wrote:
>
> > Hi,
>
> > I am still working on my plugin that this group helped me debug in the
> > past and I have an other issue, which can probably ressolve quickly
> > but i don't know how to attack the problem.
>
> > Basically my script uses the HTML class attribute in order to set
> > widgets, effects and plugins as well as passing through options (if
> > any) for the set widgets, effects and plugins.
>
> > I got it all working now, added event support, delay support, effects
> > support ect... Anyway the issue is not there, everything works ok,
> > also it can probably be optimized and cleaned up.
>
> > The issue I have is if I want to have multiple class, some that might
> > not be related to my plugin and therefor need to be left behind like:
>
> > <div class="foobox sx-fold { sxFxSpeed: 500; }"> // where foobox need
> > to be left behind and the rest extracted
>
> > And some I want to be able to have more than one special class and set
> > of options, like:
>
> > <div class="foobox sx-draggable { options} sx-resizable {options}"> //
> > here foobox is left behind but the rest need to be recorded
>
> > To be honest I have no idea on how to go and do that, I think the
> > option I can use the same code and just check for m[0], m[1], m[2]
> > ect...
>
> > But the problem is as soon as I introduce an other class the plugin
> > just doesn't pick up anything anymore.
>
> > The plugin in action:http://codeserenity.com/jquery/scriptless/demoX4.html
> > The plugin
> > code:http://codeserenity.com/jquery/scriptless/js/jquery.scriptlessX4.js
>
> > If anyone could point me in the right direction that would be lovely
> > and make sure to point out again everything I do wrong or that could
> > be done better in the code as I always learn a lot from you guys and
> > still have TONNES to learn as some of my attempt to help other often
> > show :p
>
> > Thanks in advance.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---