Here is a useful method to accomplish this task.
The jquery ui widgets trigger a 'create' event that occurs between the _create() and _init() methods:
this._create();
this._trigger( "create" );
this._init();
This event originates from the base object Widget, making it accessible for all implementing widgets.
The classes like 'ui-corner-xxx' are usually generated in the '_create()' method, so you can associate an event handler with the 'create' option of the widgets to eliminate those classes. A sample code snippet could be:
var classesToRemove = ['ui-corner-all', 'ui-corner-top',
'ui-corner-bottom', 'ui-corner-right', 'ui-corner-left',
'ui-corner-tl', 'ui-corner-tr', 'ui-corner-bl', 'ui-corner-br'];
var removeClassesCreateHandler = function(event, ui) {
var that = this;
$.each(classesToRemove, function(idx, val) {
$('.' + val, that).removeClass(val);
});
};
$("#accordion").accordion({
create: removeClassesCreateHandler
});
An illustration of this concept can be found on jsfiddle.
Exploring the create
event of jQuery UI Widgets
It is essential to understand that not all jQuery ui widgets utilize the Widget Factory (although it is achievable through the aforementioned solution).
Therefore, even though the documentation includes a create
option, it may not always be present.
For example, the Datepicker widget does not currently implement the Widget Factory as it still relies on older code (although plans for refactoring are underway).