开发者

jquery don't continue executing rest of javascript code

This is my first question on this site (but the other discussions have helped me).

In the following code:

$('#selObra').change(function() {
      var id_obra = $(this).val();
      if (id_obra == '-1') {
        //Elimino todos los renglones de la tabla
        $('#tblSubcontratos tbody tr').remove();
      } else {
        $('#tblSubcontratos').append('<tr><td class="center" colspan="6"><img src="images/ui-anim_basic_16x16.gif" height="16" width="16" style="margin-left:auto;margin-right:auto" /></td></tr>');
        //Obtengo todos los contratos de la obra seleccionada
        $.ajax({
          type: 'GET',
          dataType: 'xml',
          url: 'get_subcontratos.php',
          data: 'id_obra=' + id_obra,
          succes开发者_高级运维s: function(xml) {
            $('#tblSubcontratos tbody tr').remove();
            if ($(xml).find('subcontratos').attr('status') == 'OK') {
              $(xml).find('subcontrato').each(function(){
                var id_subcontrato = $(this).find('id_subcontrato').text();
                var id_obra = $(this).find('id_obra').text();
                var nombre_obra = $(this).find('nombre_obra').text();
                var id_contratista = $(this).find('id_contratista').text();
                var nombre_contratista = $(this).find('nombre_contratista').text();
                var fecha_subcontrato = $(this).find('fecha_subcontrato').text();
                var strRow = '<tr class="ui-widget-content">' +
                               '<td>' + id_subcontrato + '</td>' +
                               '<td>' + nombre_obra + '</td>' +
                               '<td>' + nombre_contratista + '</td>' +
                               '<td>' + fecha_subcontrato + '</td>' +
                               '<td class="center view_details"><img src="images/view.gif" /></td>' +
                               '<td class="center"><input type="radio" name="subcontratoSeleccionado" /></td>' +
                             '</tr>';
                $('#tblSubcontratos tbody').append(strRow);
              });
            } else {
              var errno = $(xml).find('errno').text();
              var error = $(xml).find('error').text();
              $('#message').html(errno + ' - ' + error);
              $('#message').dialog('open');
            }
          }
        });
      }
      $("#divSubcontratos").dialog( "option", "position", 'center' );
    });

Centering the dialog is never executed... I can't see the mistake, the last line that firebug higlights is the bracket to close the else instruction... any comments will be appreciated. Thanks in advance.

Marco.


Two things I note:

  • I see that you're calling dialog on #divSubcontratos, but I don't see that anywhere in the code. I'll assume it already exists at the point the code is being run, but it's worth mentioning
  • As mentioned by Nico, you might want to move the command to center the div into the ajax callback, so you know it's all setup before it runs.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜