Interpreting jquery-ui-tabs content

I use jquery-ui-tabs so that users can create their own tabs and then switch between tabs as they see fit. The content in widgets is small widgets that look like mini-programs. Then users can choose which widgets they want on any tab.

This works fine as long as any widget is installed only on tab 1, however, everything starts to go wrong when any widget is added to 2 tabs or more. When widgets are generated, they use the identifier from the database. For instance. If this widget is added to two or more tabs, they end with two divs with id id, for example widget_1, which causes problems, as you can imagine.

So my question is: what is the best way to solve such a problem?

I wish I knew earlier that they want to have the same widget on more than one tab. I have a feeling that this will almost be a complete rewrite ...

+5
source share
2 answers

Does div named div1 have "div1" as a class or id?

your question sounds like an identifier and all this is a problem: the identifier must be unique

to solve this problem, work with classes - you can use them several times, and you should be able to do the same (but it's a little difficult to say without seeing any code).

EDIT: , w3c.

+2

id , , , javascript-, - , :

$(".tab-1 #div1")... $("#div1")...

id "" , div1-random-number , , ,

Live JsBin

-2

All Articles