Conversion from jquery to Dojo

If you had to do this..

function disableAutoComplete(id) {
    jQuery("#" + id).attr("autocomplete", "off");
}

/* Registers function for SELECT element */

function registerHandler(id, event, handler) {
    switch (event) {
    case "change":
        jQuery(document).ready(function() {
            jQuery("#" + id).change(handler);
        });
        break;
    case "click":
        jQuery(document).ready(function() {
            jQuery("#" + id).click(handler);
        });
        break;
    case "keyup":
        jQuery(document).ready(function() {
            jQuery("#" + id).keyup(handler);
        });
        break;
    case "focus":
        jQuery(document).ready(function() {
            jQuery("#" + id).focus(handler);
        });
        break;
    }
}

with dojo instead of jquery, how would you do it?

Answers


I'm not a dojo expert, you can also find this solution from documentation:

function disableAutoComplete(id) {
    dojo.attr(dojo.byId(id), "autocomplete", "off");
}

function registerHandler(id, event, handler) {
    dojo.connect(dojo.byId(id), "on" + event, handler);
}

dojo.attr(), dojo events

And that's not the jQuery way of doing things. It should be like this:

function disableAutoComplete(id) {
    jQuery("#" + id).prop("autocomplete", "off");
}

/* Registers function for SELECT element */

function registerHandler(id, event, handler) {
    jQuery("#" + id).bind(event, handler);
}

Need Your Help

Show mysql random result

php mysql

I have a mysql table named events. Some events are featured. I want to randomly display one of the two latest featured events. The field 'timestamp' holds the UNIX timestamp of the event's creation...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.