Why using class and not id

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Why using class and not id

benoit
Hi all,

  I was playing with widgets in Iliad, changing the default root element
to not having another div around my widget. Then I set the class for the
root element and *pouf* Iliad isn't working anymore.

  After digging in the framework I understand that it's not a good idea
to mesh div used as widget container and other elements used for
document presentation.

  But I wonder why is Iliad using the "class" attribute instead of the
"id" attribute to update the widget ?

Excerpt from iliad.js :
  function updateWidget(id, contents) {
                jQuery("."+id).replaceWith(contents);
        }

It seems to me, more logical to use the id, but there should be some
reason I can't see.

  function updateWidget(id, contents) {
                jQuery("#"+id).replaceWith(contents);
        }


Perplexed Benoit

--
You received this message because you are subscribed to the Google Groups "Iliad project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Why using class and not id

Nicolas Petton
> Hi all,

Hi,

>
>   I was playing with widgets in Iliad, changing the default root element 
> to not having another div around my widget. Then I set the class for the 
> root element and *pouf* Iliad isn't working anymore.
>
>   After digging in the framework I understand that it's not a good idea 
> to mesh div used as widget container and other elements used for 
> document presentation.

You can change the root element though. (There's a method for that in
ILWidget).

>
>   But I wonder why is Iliad using the "class" attribute instead of the 
> "id" attribute to update the widget ?

The reason is that the same widget might be rendered several times in
the same page. If we were using ids, it would not be possible.

HTH,
Nico

2015-03-19 22:48 GMT+01:00 benoit <[hidden email]>:
Hi all,

 I was playing with widgets in Iliad, changing the default root element to not having another div around my widget. Then I set the class for the root element and *pouf* Iliad isn't working anymore.

 After digging in the framework I understand that it's not a good idea to mesh div used as widget container and other elements used for document presentation.

 But I wonder why is Iliad using the "class" attribute instead of the "id" attribute to update the widget ?

Excerpt from iliad.js :
 function updateWidget(id, contents) {
                jQuery("."+id).replaceWith(contents);
        }

It seems to me, more logical to use the id, but there should be some reason I can't see.

 function updateWidget(id, contents) {
                jQuery("#"+id).replaceWith(contents);
        }


Perplexed Benoit

--
You received this message because you are subscribed to the Google Groups "Iliad project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Iliad project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Why using class and not id

benoit
Le 3/20/15 10:11 AM, nicolas petton a écrit :
>  >   But I wonder why is Iliad using the "class" attribute instead of the
>  > "id" attribute to update the widget ?
>
> The reason is that the same widget might be rendered several times in
> the same page. If we were using ids, it would not be possible.

  Oh, it seems obvious now that you say it.

  Well, what would be nice now that it's common to have multiple css
class on one html element would be to make Iliad more aware of it. To be
able to change the css class of a widget without breaking this mecanism.
  I will look into it.


  By the way I have added the caption element from a table to Iliad. You
can found the code on Smalltalk Hub :
http://smalltalkhub.com/#!/~BenoitAstruc/Iliad.

Benoit

--
You received this message because you are subscribed to the Google Groups "Iliad project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.