开发者

What convention should I use while choosing css class name for a jQuery widget

While creating a jQuery widget, what convention should I use to name my CSS classes. 开发者_JAVA百科jQuery uses a 'ui-' prefix followed by the plugin name and a class specific name (example : ui-datepicker-header).

Should I use this convention? Or is the 'ui' prefix "reserved" for jQuery's official use only?


When deciding things like this, think about how someone knowing nothing about your code would read it.

I wouldn't use the "ui-" prefix because such a person might think it's jQuery UI related.

You don't need to use a prefix. In most cases this is "noise". If everything starts with "foo-" why have it? It makes sense for a library because then you can easily distinguish what "belongs" to the library. For your own code, it's assumed that everything that doesn't belong to a library belongs to your application.

Pick a meaningful name for each thing that is short but not too short.


Avoid using "reserved" one, use your own but make sure that overall name does not conflict with any of existing plugins/widgets.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜