2011-10-14 26 views
5

Estoy intentando crear un diálogo modal en SharePoint 2010, pero estoy recibiendo este error:

TypeError: this.$E_0.getElementsByTagName is not a function 

mi código es:

var options = SP.UI.$create_DialogOptions(); 
options.html = '<div class="ExternalClass23FFBC76391C4EA5A86FC05D3D9A1904"><p>RedConnect is now available.​</p></div>'; 
options.width = 700; 
options.height = 700; 
SP.UI.ModalDialog.showModalDialog(options); 

usando firebug, intenté simplemente usar el campo url en lugar del campo html y no dio ningún error.

también relacionado con esto, ¿qué hace realmente SP.UI. $ create_DialogOptions()? ¿Cuál es la diferencia entre usarlo y simplemente usar un dict de valores para sus opciones?

Respuesta

7

options.html requiere un elemento HTML DOM en lugar del código HTML plano:

<script> 

    function ShowDialog() 
    { 
    var htmlElement = document.createElement('p'); 

    var helloWorldNode = document.createTextNode('Hello world!'); 
    htmlElement.appendChild(helloWorldNode); 

    var options = { 
     html: htmlElement, 
     autoSize:true, 
     allowMaximize:true, 
     title: 'Test dialog', 
     showClose: true, 
    }; 

    var dialog = SP.UI.ModalDialog.showModalDialog(options); 
    } 

</script> 

<a href="javascript:ShowDialog()">Boo</a> 

código Ejemplo tomado de la entrada del blog Rendering html in a SharePoint Dialog requires a DOM element and not a String.

also related to this, what does SP.UI.$create_DialogOptions() actually do? what is the difference between using it and simply using a dict of values for your options

Cuando nos fijamos en la definición de la "clase" SP.UI.DialogOptions en el archivo SP.UI.Dialog.debug.js se ve que es una función de JavaScript vacío.

SP.UI.DialogOptions = function() {} 
SP.UI.$create_DialogOptions = function() {ULSTYE:; 
    return new SP.UI.DialogOptions(); 
} 

Supongo que está ahí para fines de diagnóstico del cliente. Eche un vistazo a esta pregunta ASÍ: What does this Javascript code do?

+1

Sí ... lo descubrí un par de horas más tarde y iba a publicar la respuesta, pero todavía no tenía suficientes representantes :) gracias por la respuesta a $ create_DialogOptions pregunta – Nacht

Cuestiones relacionadas