Widget Ids Autogeneration

Hi

I came into a problem with rendering widgets (with no IDs specified) on ajax-loaded views. Current strategy causes JS mess, becouse IDs like yw0, yw1 are repeated.

I suggest

  1. moving ID autogeneration to widget factory, so I can easily change the way IDs are generated by making my own widget factory class

  2. replacing widget counting numbers with random hash in default autogeneration

best regards

You can always specify a custom ID ;)

obviously, but we’re speaking about how to make Yii even better than it is now

it’d be nice to have possibility to control widget ids autogeneration

Yii generated unique IDs per requests that is typical case. If multiple requests are used to generate the page you should specify IDs yourself. If we’ll try to generate really unique IDs will be something like “yw550e8400-e29b-41d4-a716-446655440000”.

We could argue which case is typical.

Nowadays ajax interface is a standard. Workaround of the issue is obvious, but the thing is to make life easier.

You don’t need to use GUID to achive small repeat probability, on the other hand this hash realy doesn’t mather, becouse nobody will directly use it in for example JS since it wasn’t specified by programmer. For appliaction yw0 or yw{whatever} is just the value.

Far more important then default autogeneration strategy is moving it to the place (widget factory for me is the best choice) developers can easily change it.

I usually use ids like “mywidget-”.time() for stuff that loads via ajax, but it would be nice to automate that :)

Recently I develop ajax-based interface application, so almost every request is ajax in my case. And i have to specify ID for every (even tiniest button) widget to keep the JS stable and consistent, otherwise it would throw yw0 stuff all over the DOM, making lots of difficult to debug mess. It’s a bit annoying.