Asp.Net MVC + dojo dialog update
Friday, August 7th, 2009I’ve made some changes to the showDialog function I discussed in this post. I’ve made it more generic – it now takes dialogId, href, title, queryString, and onDownloadend (a function). That way I can use it to open any dialog in my application. I’m also now not destroying the dialog if it already exists, I’m just resetting the onDownloadEnd and title properties and using my custom setTitle method:
//extend dojo dialog to have a setTitle method
dojo.extend(dijit.Dialog, {
setTitle: function(/*string*/title)
{
this.titleNode.innerHTML = title || "";
}
});
Finally, I’m using the href property instead of setHref which is deprecated. Here’s the new showDialog function:
showDialog: function(dialogId, href, title, onDownloadEnd)
{
//first check if it's there so we don't create a duplicate
var dialog = dijit.byId(dialogId);
if (dialog)
{ //it already exists, reset a few properties
dialog.setTitle(title);
dialog.onDownloadEnd = onDownloadEnd;
dialog.href = href;
}
else
{ //it doesn't exist yet, so create it
dialog = new dijit.Dialog({
refreshOnShow: true,
id: dialogId,
href: href,
title: title,
onDownloadEnd: onDownloadEnd,
onDownloadError: dojo.hitch(this, '_dialogDownloadError', dialogId)
});
}
//show it
dialog.show();
}