javascript - Jquery dialogs interfering between them -


i not js guy. have 2 js functions.

    $(document).ready(function () {      $(function () {         $("#dialog").dialog({             autoopen: false,             modal: true,             width: 500         });         $("#button").on("click", function () {             $("#dialog").dialog("open");         });     });   });  function editar(id) {     $.ajax({         url: "../controllers/editarevento_controller.php?idevento="+id,         success: function (data) {             $("#editarevento").html(data).dialog({                 modal: true,                 width: 500             }).dialog("open");         }     }); } 

how html buttons , divs like.

<input id="button" type="button" class="botonanadir" value="+añadir evento"> <input type='button' class='botongris' onclick='editar(some id);' value='editar'/>  <div id="dialog" title="añadir un evento"> form inside </div>  <div id="editarevento" title="editar evento"></div> 

once time click on editarevento can't open dialog anymore , throws me :

" error: cannot call methods on dialog prior initialization; attempted call method 'open'".

i guess have ready function, have no idea, taking functions places :/

thanks.

use following syntax while printing php variable's value in html: <?php echo $id; ?>

<input type='button' class='botongris' onclick='editar("<?php echo $id; ?>");' value='editar'/>                                                         ^^^^^^^^^^^^^^^^^^ 

you don't have use both

  • $(document).ready(function () {
  • $(function () {

both same. can use 1 of them like:

$(function () {//or $(document).ready(function () {     $("#dialog").dialog({         autoopen: false,         modal: true,         width: 500     });     $("#button").on("click", function () {         $("#dialog").dialog("open");     }); });  

Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -