Miro
Miro

Reputation: 11

Dojo dialog dynamic content

I would like to ask you, how can I dynamicaly create HTML content with using javascript. It means, that I need create simply dojo dialog and than I "tell him" with another js file, which content it can show. Or I have html file, which contains some calling on javascript functions, but it doesnt work. Static tags are showed, but js doesnt render content. It is possible with dojo something like this, because I didnt find something.

Miro

Upvotes: 1

Views: 5338

Answers (1)

Ryan Ransford
Ryan Ransford

Reputation: 3222

It's pretty easy in dojo to create a dialog and give it some content from javascript on a page. The easiest method I have found so far is to create the dialog in dojo-flavored javascript, then create content in it's containerNode using dojo.create.

dojo.require('dijit.Dialog');

function showDialog() {
  var dialog = new dijit.Dialog({ title: 'Confirmation' });
  dojo.create('div', {
    innerHTML: 'Are you sure you want to do this?'
  }, dialog.containerNode /* the content portion of the dialog you're creating */);
  var div = dojo.create('div', {}, dialog.containerNode);
  dojo.create('a', {
    href: '#',
    innerHTML: 'Yes',
    onClick: function() {
      /* do yes stuff */
    }
  }, div);
  dojo.create('a', {
    href: '#',
    innerHTML: 'No',
    onClick: function() {
      /* do no stuff */
      dialog.hide();
      dojo.destroy(dialog);
    }
  }, div);

  dialog.show();
}

Upvotes: 1

Related Questions