Yii Framework Forum: Widget Ids Autogeneration - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Widget Ids Autogeneration strategy proposition Rate Topic: -----

#1 User is offline   Pio 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 28-November 13
  • Location:Poland

Posted 28 November 2013 - 04:00 AM

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
0

#2 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,349
  • Joined: 12-October 09
  • Location:Croatia

Posted 28 November 2013 - 04:22 AM

You can always specify a custom ID ;)
Find more about me.... btw. Do you know your WAN IP?
0

#3 User is offline   Pio 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 28-November 13
  • Location:Poland

Posted 28 November 2013 - 06:21 AM

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
0

#4 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,466
  • Joined: 17-January 09
  • Location:Russia

Posted 28 November 2013 - 07:08 AM

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".
Yii 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
0

#5 User is offline   Pio 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 28-November 13
  • Location:Poland

Posted 30 November 2013 - 08:42 AM

View Postsamdark, on 28 November 2013 - 07:08 AM, said:

Yii generated unique IDs per requests that is typical case.


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.
0

#6 User is offline   andy_s 

  • Random Member Title
  • Yii
  • Group: Moderators
  • Posts: 1,526
  • Joined: 22-June 09
  • Location:Russia, Kostroma

Posted 01 December 2013 - 02:42 AM

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

#7 User is offline   Pio 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 28-November 13
  • Location:Poland

Posted 02 December 2013 - 03:06 PM

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.
0

#8 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,466
  • Joined: 17-January 09
  • Location:Russia

Posted 12 December 2013 - 05:46 PM

https://github.com/y...0f807477018681d
Yii 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users