Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Special css class names for developers
#1
How about having special class names that can be used by developers for extra functionality (JavaScript interactivity wise)?

For example have an input
Code:
<input name="event_date" class="date" />
and when you click on it a date picker shows? Or <textarea class='rte'></textarea> and you get a rich text editor.

Then with jQuery in document.ready (assuming jQuery UI datepicker and the CKEditor jQuery Adapter are loaded, but can check just in case they are not).

Code:
if($.fn.datepicker) $("input.date").datepicker();
if($.fn.ckeditor) $("textarea.rte").ckeditor();

Could also be used for styling purposes as well, i.e. with class 'date' or 'time' the input would be narrower, or class 'widetext' would be full width.
-- Sam
Reply
#2
What form elements can’t be targeted as it is?

JavaScript has no problem targeting form elements by their name-attribute btw, so that can’t really be it.
“Don’t forget the important ˚ (not °) on the a,” says the Unicode lover.
Help us test a key change for the core! ¶ Problems with GetSimple? Be sure to enable debug mode!
Reply
#3
If a developer knew that if all they had to do is add a class to an input and a datepicker would show when the input is clicked, it would mean that they would not have to write any JavaScript (some may be uncomfortable with that, i.e. new to developing or only experienced in PHP).

If less work is needed by a developer to add JavaScript functionality (date picker, fancybox, accordian, tooltips etc), then the quality of plugins would be improved and would also save them development time.

This could be possible through a plugin that adds the javascript/css to the template <head> (via the 'header' hook), rather than editing the core code of GetSimple.
-- Sam
Reply




Users browsing this thread: 1 Guest(s)