0

In my project, I use easyui-layout, which has west and center region.

When i click easyui-linkbutton announcement, oat.php will return table content which will be included in cenDiv successfully.

Here is my js code:

function corpAnn()
{
var oaAnn="annIn";
 $.ajax({
        dataType:'html',
        type:"POST",
        url:"oat.php",
        data: {oaAnn:oaAnn},
        success:function(data)
        {
            $('#cenDiv').html(data);
        }
      });
}

Here is my html code:

<div id="firDiv" class="easyui-layout">
    <div id="wesDiv" data-options="region:'west',split:true" >
    </div>
    <div id="cenDiv" class="easyui-layout" data-options="region:'center',title:''">
    </div>
</div>

<a href="javascript:void(0)" class="easyui-linkbutton" onclick="corpAnn()">announcement</a><br />

Here is oat.php code:

echo '<div id="tbbs" class="easyui-panel" title="Panel Footer" style="width:100%;height:80%;border:1px solid #A9A9A9 ;" data-options="footer:\'#ft\'">';
echo '<table id="bbs" class="cenClass" border=1px cellspacing=0 align="center" width="100%">';
......
echo '</table>';
echo '</div>';

And then, I want to doubleclick table tr, which will call alert method.

But unfortunately, it worked fail. Here is my js test code:

$(document).ready(function()
{
 $('#cenDiv').on("dblclick","#tbbs #bbs td",function(){
    alert("thsTest");
});
});

I know when loading my main web page, tbbs and bbs id are not exit in DOM.So I should rebond them to cenDiv id.But I don't know how. Who can help me?

Snow
  • 71
  • 1
  • 11
  • Does `$('#cenDiv')` exist in page when code is run and stay in page all the time? – charlietfl Nov 24 '17 at 02:15
  • yes,$('#cenDiv') exist when webpage loading first time – Snow Nov 24 '17 at 02:20
  • What you are showing sure seems all correct and should work. Is there any other plugin acting on the table? – charlietfl Nov 24 '17 at 02:24
  • God !!, you are right.The problem is that I have defined a $('#fstDiv') before $('#cenDiv') in $(document).ready method. but fstDiv is non-existent id in html code. Thank you very much for your kindly heart. – Snow Nov 24 '17 at 03:07

0 Answers0