cdotyone / mochaui

development tree for MochaUI
http://mochaui.org/demo/
Other
290 stars 83 forks source link

Send HTML to a modal (no request) #105

Closed partikule closed 12 years ago

partikule commented 13 years ago

When setting HTML content to a modal, the content isn't displayed.

Basically, what I do :

// Creation of the HTML content... More complete in the real world :-)
var wMessage = new Element('div', {'class':'message'}).set('text', 'This is my user message');
var wContent = new Element('div').adopt(wMessage);

// I set my options
var options = {
    id: 'wdelconfirm0',
    content: wContent,
    title: 'The window title',
    cssClass:'confirmation',
    draggable: true,
    padding: { top: 15, right: 15, bottom: 8, left: 15 }  
}
// Modal creation
new MUI.Modal(options);

The problem is in window.js line 1141, the type of the content option is 'element', so the switch case will be 'default' and the content is pushed to the sections array. :

switch (typeOf(options.content)){
    case 'string':
        // was passed html, so make sure it is added
        this.sections.push({
            loadMethod:'html',
            content:options.content
        });
        break;
    case 'array':
        this.sections = options.content;
        break;
    default:
        /*
        * HTML Element will be considered here....not correct
        */
        this.sections.push(options.content);
}

Proposed solution :

switch (typeOf(options.content)){
    case 'string':
    case 'element':
        /*
        * HTML Element will now be considered here....
        */
        // was passed html, so make sure it is added
        this.sections.push({
            loadMethod:'html',
            content:options.content
        });
        break;
    case 'array':
        this.sections = options.content;
        break;
    default:
        this.sections.push(options.content);
}
cdotyone commented 13 years ago

Thanks for the fix.

cdotyone commented 12 years ago

Code added to develop branch.