javascript - Unable get the value of textarea inside jquery ui dialog -


i tried put textarea inside dialog box , want value of textarea if "ok" click can't value. might problem?

$(document).on('click', '#open', function () {      var txt = $('#txt').val();      $('#break-diag').dialog({          modal: true,          title: 'dialog',          show: {              effect: "scale",              duration: 200          },          resizable: false,          buttons: [{              text: "ok",              click: function () {                  console.log(txt);              }          }]      });  });
#break-diag{      display:none;  }
<link href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css" rel="stylesheet"/>  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>  <button id="open">open dialog</button>  <div id="break-diag">      <textarea id="txt"></textarea>  </div>

you capturing textarea value on click of open; empty during event.

the value should captured on click of ok

click: function () {        var txt = $('#txt').val();        console.log(txt); } 

Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -