Reputation: 4315
I'm new to dojo. I write a application for modern browsers (CSS3/HTML5). On some pages I need a button that perform a simple action. I just wrote the button like that :
<button class="myButtonClass" data-dojo-attach-event="click:myCallback">Click me</button>
And i don't need anything else. But my collegues with longer Dojo experience says I'm wrong, I should use the dijit widget and not an html button, so I should write :
<button data-dojo-type="dijit/form/button" data-dojo-attach-event="click:myCallback">Click me</button>
The behaviour is the same, but dojo replace my button
tag by a lot of complicated span
and div
tags that is pain to understand and to customize (imho). My collegues just argue: "this is the correct way to do in Dojo". What are the benefits of data-dojo-type="dijit/form/button"
in this case, when Vanilla/CSS3 and attach-event does the job ?
Upvotes: 0
Views: 165
Reputation: 1002
In terms of functionality, I have not encountered a situation yet, where DOJO buttons prove to be of more use that a simple HTML button.
If you just want to customize the button and enhance its look and feel, IMHO it can be done in simple HTML button as well. Using DOJO buttons sometimes creates difficulty in understanding its HTML and CSS (because there is a lot of HTML and classes for just a button! ). I was faced with the same dilemma a while back and I decided to use HTML buttons.
The problem occurs when we talk about the User Experience, as styling a HTML button and DOJO button may not result in the same look and feel. At that point, it it better to stick with whatever is currently being used.
Upvotes: 2
Reputation: 3568
There is no "must do". There is only guide lines and team decisions.
Both syntax are valid. It is simply a matter of coding standards and/or needs.
If the application you are developing use dijit button, then for consistency reason, you'd better stick with it.
In other hand, dijit buttons are heavily configurable. If you don't need super generic component, and you want to work on optimizing the dom, then button tag is ok...
All in all it is just a matter of choice. But for sure, if the app already contains some dijit button, you should stick with them (or replace them all), otherwise the user experience will be bad.
Upvotes: 2