質問

Hi i have a cfoutput to loop a query and i'm using dynamic variables to display the layout in client's side, every works fine except for the binding that only works when i'm not using jquery's modal.

there's my coldfusion code

<cfoutput query = "RSSelect.rs">
<div id="editar_#idu_programa_detalle#" title="Editar">
<table>
    <tr>
        <td align="right" valign="middle">Estado:</td>
        <td align="left" valign="middle">
            <cfselect 
                title="id_Estado" 
                selected="#RSSelect.RS.idu_estado_salida#" 
                id="idu_estado_salida_#idu_programa_detalle#" 
                name="idu_estado_salida_#idu_programa_detalle#" 
                query="RSEstados.RS" 
                display="nb_Estado" 
                value="id_Estado" 
                queryPosition="below" 
                style="width:200px" 
                required="yes" 
                message="El estado es requerido" 
            >
                <option value="0" >Seleccione estado  </option>
            </cfselect>&nbsp;&nbsp;
        </td>
        <td align="left" valign="middle">Ciudad:
            <cfselect 
                title="Seleccione ciudad" 
                selected="#RSSelect.RS.idu_ciudad_salida#" 
                name="idu_ciudad_salida_#idu_programa_detalle#" 
                id="idu_ciudad_salida_#idu_programa_detalle#" 
                bind="cfc:#Application.CfcPath#.solicitudes_cm_uo.obtenerCiudades({idu_estado_salida_#idu_programa_detalle#@change})" 
                bindonload="yes"  
                value="id_Ciudad" 
                display="nb_Ciudad" 
                queryPosition="below"  
                style="width:200px" 
                required="yes" 
                message="El campo ciudad no debe de quedar vacio"
            >
            </cfselect>
        </td>
    </tr>
</table>
</div>
</cfoutput>

and jquery code

<link rel="stylesheet" href="../css/smoothness/jquery-ui.css" />
    <script src="../js/jquery-1.9.1.js"></script>
    <script src="../js/jquery-ui.js"></script>
    <cfoutput query = "RSSelect.rs">
        <script>
            $(function()
            {
                $( "##editar_#idu_programa_detalle#" ).dialog(
                {
                    modal:true,
                    autoOpen: false,
                    height:999,
                    width:999,
                    buttons:
                    {
                        "Editar": function()
                        {
                            alert('se edito correctamente');
                            $( this ).dialog( "close" );
                        },
                        "Cancelar": function()
                        {
                            alert('se cancelo correctamente');
                            $( this ).dialog( "close" );
                        }
                    }
                });
            });
        </script>
        </cfoutput>

I'd apreciate your help.

I tried using showmodaldialog as well but it only works on IE

any other options using a modal dialog would be ok.

役に立ちましたか?

解決 2

Basically a call a function to open the modal dialog.

Well i think I coded too much but here it is =).

<script language="javascript">
function OpenPop(idu_programa,idu_programa_detalle)
{
    var x = false;
    //alert('algo');
    x = showModalDialog('pop_editar_detalle_supervision.cfm?idu_programa='+idu_programa+'&idu_programa_detalle='+idu_programa_detalle,'dialogHeight:1000px;dialogWidth:1000px;');
    if (typeof x == 'undefined')
    {
        alert('Edicion cancelada');
    }
    else
    {
        document.getElementById('idu_programa_detalle_pop').value = idu_programa_detalle
        document.getElementById('idu_estado_salida_pop').value = x[0];
        document.getElementById('idu_ciudad_salida_pop').value = x[1];
        document.getElementById('fec_salida_pop').value = x[2];
        document.getElementById('opc_meridiano_salida_pop').value = x[3];
        document.getElementById('fec_supervision_inicial_pop').value = x[4];
        document.getElementById('fec_supervision_final_pop').value = x[5];
        document.getElementById('opc_meridiano_supervision_inicio_pop').value = x[6];
        document.getElementById('form1').submit();
    }       
}
</script>

Then I returned the values on an array then i put the values on hidden inputs to call them after submit

Here is the modal javascript code that returns the array.

<script language="javascript">
function Editar()
{
    var valoresDevueltos = new Array();
    valoresDevueltos[0] = document.getElementById('idu_estado_salida').value;
    valoresDevueltos[1] = document.getElementById('idu_ciudad_salida').value;
    valoresDevueltos[2] = document.getElementById('fec_salida').value;
    if(document.getElementById('amSalida').checked)
    {
        valoresDevueltos[3] = document.getElementById('amSalida').value;
    }
    else
    {
        valoresDevueltos[3] = document.getElementById('pmSalida').value;
    }
    valoresDevueltos[4] = document.getElementById('fec_supervision_inicial').value;
    valoresDevueltos[5] = document.getElementById('fec_supervision_final').value;
    //Checking which radioButton is checked
    if(document.getElementById('amSupervision').checked)
    {
        valoresDevueltos[6] = document.getElementById('amSupervision').value;
    }
    else
    {
        valoresDevueltos[6] = document.getElementById('pmSupervision').value;
    }
    window.returnValue = valoresDevueltos;
    window.close();
}
</script>

Hope it is clear enough if not let me know to improve my answer thank you for your patience =)

他のヒント

It appears as though your jQuery code is contained within the header of your HTML document. Of course your CFML is contained within the body of your HTML document. When using jQuery you need to be careful that you only access items in the DOM when they are available. You can avert some of these issues by wrapping your jQuery code within the $(document).ready() function. Something like this...

<cfoutput query = "RSSelect.rs">
    <script>
        $(document).ready(function()
        {
            $( "##editar_#idu_programa_detalle#" ).dialog(
            {
                modal:true,
                autoOpen: false,
                height:999,
                width:999,
                buttons:
                {
                    "Editar": function()
                    {
                        alert('se edito correctamente');
                        $( this ).dialog( "close" );
                    },
                    "Cancelar": function()
                    {
                        alert('se cancelo correctamente');
                        $( this ).dialog( "close" );
                    }
                }
            });
        });
    </script>
</cfoutput>

Here is the documentation on the ready() function.


Initial issue that has since been corrected in the question

I'm not sure if this is the issue but your <div> tags are not positioned correctly. The opening <div> tag is within the <cfoutput> block...

<cfoutput query = "RSSelect.rs">
<div id="editar_#idu_programa_detalle#" title="Editar">

but the closing tag is after the </cfoutput> and thus outside the loop...

</cfoutput>
</div>

The closing </div> tag should be within the cfoutput block, so that each opened div is also closed...

</div>
</cfoutput>
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top