2010-11-24 14 views
21

HIestablece el ancho modal de diálogo para jquery ui?

estoy usando this demo para mostrar un diálogo modal

cómo fijo el ancho de diálogo si lo estoy usando para Google Street View:

var point = new GLatLng(svlat, svlon); 
var panoClient = new GStreetviewClient(); 
panoClient.getNearestPanoramaLatLng(point, function (newPoint) { 
    if (newPoint == null) { 
     alert("no panorama found for this position!!"); 
     return; 
    } 
    panoramaOptions = { latlng: newPoint }; 
    myPano = new GStreetviewPanorama(document.getElementById("pano"), panoramaOptions); 
    $('#dialogStreetView').dialog("option", "maxWidth", 600); 
    $('#dialogStreetView').dialog('open'); 
    GEvent.addListener(myPano, "error", handleNoFlash); 
}); 

HTML:

<div id="dialogStreetView" title="Street View Provided by Google... "  style="width:300px;height:300px"> 
    <a id="closestreet-view" name="closestreet-view" style="cursor:pointer; text- decoration:underline" >Close</a> 
    <div name="pano" id="pano" style="width: 300px; height: 300px"></div> 
</div> 

Respuesta

35

De los documentos:

esto debería funcionar:

$("#dialogStreetView").dialog("option", "width", 460); 
+0

yo probamos este $ ('# dialogStreetView'). De diálogo ("opción", "anchoMax", 600) ;, que es sólo la anchura, necesito un café, – Bart

+0

Bueno, en realidad hay un ' maxWidth' como una opción separada. Verifique los documentos, y sí, un café funciona bien :) –

+0

Y si desea hacer esto cuando se abre el cuadro de diálogo, asegúrese de adjuntar lo anterior al evento de creación, no al evento abierto. – rakensi

17
<script src="http://code.jquery.com/jquery-1.9.1.js"></script> 
    <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" /> 
    <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script> 
<script> 
$(function() { 
$("#myDialogBox").dialog({ 
    width: 500, 
    autoOpen: false, 
    show: { 
    effect: "blind", 
    duration: 1000 
    }, 
    hide: { 
    effect: "blind", 
    duration: 1000 
    } 
}); 
$("#myBoxOpener").click(function() { 
    $("#myDialogBox").dialog("open"); 
}); 
}); 
</script> 

cuerpo ====== ======

<div id="myDialogBox" title="My Dialog Box"> 
    <div id="myContentLayer"> 
    <p>My Content</p> 
    </div> 
</div> 
<button id="myBoxOpener" class="myButton">Open Dialog Box</button> 

jsFiddle Demo

3

simplemente solo agrega widt h: 500

$('#dialogStreetView').dialog(width: 500,"option", "maxWidth", 600); 
Cuestiones relacionadas