使用jquery easyui,如何通过选项卡中的链接创建选项卡?

标签文件

我想从选项卡中的链接创建一个新选项卡。

例如,在标签a中,有一个链接“打开标签b”,它应该添加标签b,

当链接不在选项卡中时,我尝试了创建选项卡的方式(这是有效的)

但是,在这种情况下,当我按它时,它没有响应。 谢谢

Manage List 

addtabfunction

 function addTab(title, url){ if ($('#tt').tabs('exists', title)){ $('#tt').tabs('select', title); } else { var content = ''; $('#tt').tabs('add',{ title:title, content:content, closable:true }); } } 

完整页面

      @import "../plugin/easyui/themes/default/easyui.css"; @import "../plugin/easyui/themes/icon.css"; @import "../plugin/bootstrap/css/bootstrap.css"; @import "../plugin/bootstrap/css/bootstrap-responsive.css"; @import "../style/form.css";      $(document).ready(function(){ $("#addlist").validate(); }); function addTab(title, url){ if ($('#tt').tabs('exists', title)){ $('#tt').tabs('select', title); } else { var content = ''; $('#tt').tabs('add',{ title:title, content:content, closable:true }); } } $(function(){ $("#closeTab").click(function() { $.post("clear.php",function(data){ window.parent.$('#tt').tabs('close','Create List'); location.reload(); }); }); });    

Create your new subscriber list

Create a new list before adding subscriber

<input id="lname" name="lname" class="required" />

Email me when ...

<input type="checkbox" class="checkbox" name="subscribe" value="1" > <input type="checkbox" class="checkbox" name="unsubscribe" value="1" >



prepare($sql); $stmt->execute(array($_SESSION['username'])); $result= $stmt->fetchAll(); $numRows= $stmt->rowCount(); } catch(PDOException $e) { die ($e->getMessage().' Back'); } if ($numRows == 0) { echo '
You have not created any list yet.
';} else { echo '

Your Subscriber List

You have created '.$numRows.' list(s).

'; foreach ($result as $set) { try{ $sql = ' SELECT ls.SubID FROM list_sub ls,user_list ul WHERE ul.UserID=? AND ls.ListID='.$set['ListID'].' AND ls.ListID=ul.ListID '; $stmt = $conn->prepare($sql); $stmt->execute(array($_SESSION['username'])); $numSubs= $stmt->rowCount(); } catch(PDOException $e) { die ($e->getMessage().' Back'); } echo 'List Name : '.$set['ListName'].'

'; echo 'Number of subscriber : '.$numSubs.'

'; echo 'Create Date : '.$set['CreateDate'].'

'; ?>Manage List<? echo '

'; }} ?>



prepare($query); $stmt->execute(); $result= $stmt->fetchAll(); $num_rows= $stmt->rowCount(); } catch(PDOException $e) { die ($e->getMessage().' Back'); } $conn = null; if ($num_rows == 0) { echo '
There are no public list.
';} else { echo '

Public Subscriber List

There are '.$num_rows.' list(s).

'; foreach ($result as $set) { try{ $sql = ' SELECT ls.SubID FROM list_sub ls,user_list ul WHERE ul.UserID=? AND ls.ListID='.$set['ListID'].' AND ls.ListID=ul.ListID '; $stmt = $conn->prepare($sql); $stmt->execute(array($_SESSION['username'])); $numSubs= $stmt->rowCount(); } catch(PDOException $e) { die ($e->getMessage().' Back'); } echo 'List Name : '.$set['ListName'].'

'; echo 'Number of subscriber : '.$numSubs.'

'; echo 'Create Date : '.$set['CreateDate'].'

'; echo "Manage List"; // **********************the add tag link is here***************************// echo '

'; }} ?>

更新:

添加代码后仍然没有响应?

  @import "../plugin/easyui/themes/default/easyui.css"; @import "../plugin/easyui/themes/icon.css"; @import "../plugin/bootstrap/css/bootstrap.css"; @import "../plugin/bootstrap/css/bootstrap-responsive.css"; @import "../style/form.css";      $(document).ready(function(){ $("#addlist").validate(); }); $(function(){ $("#closeTab").click(function() { $.post("clear.php",function(data){ window.parent.$('#tt').tabs('close','Create List'); location.reload(); }); }); }); function addTab(title, url){ if ($('#tt').tabs('exists', title)){ $('#tt').tabs('select', title); } else { var content = ''; $('#tt').tabs('add',{ title:title, content:content, closable:true, tools:[{ iconCls:'icon-mini-refresh', handler:function(){ var tab = $('#tt').tabs('getSelected'); $('#tt').tabs('update', { tab: tab, options:{ title:title, content:content, closable:true } }); } }] }); } } function init() { $("#addtab1").on("click",function() { addTab("slashdot","http://www.slashdot.org/"); }); $("#addtab2").on("click",function() { addTab("slashdot","http://www.slashdot.org/"); }); } $(init);    

Create your new subscriber list

Create a new list before adding subscriber

<input id="lname" name="lname" class="required" />

Email me when ...

<input type="checkbox" class="checkbox" name="subscribe" value="1" > <input type="checkbox" class="checkbox" name="unsubscribe" value="1" >



prepare($sql); $stmt->execute(array($_SESSION['username'])); $result= $stmt->fetchAll(); $numRows= $stmt->rowCount(); } catch(PDOException $e) { die ($e->getMessage().' Back'); } if ($numRows == 0) { echo '
You have not created any list yet.
';} else { echo '

Your Subscriber List

You have created '.$numRows.' list(s).

'; foreach ($result as $set) { try{ $sql = ' SELECT ls.SubID FROM list_sub ls,user_list ul WHERE ul.UserID=? AND ls.ListID='.$set['ListID'].' AND ls.ListID=ul.ListID '; $stmt = $conn->prepare($sql); $stmt->execute(array($_SESSION['username'])); $numSubs= $stmt->rowCount(); } catch(PDOException $e) { die ($e->getMessage().' Back'); } echo 'List Name : '.$set['ListName'].'

'; echo 'Number of subscriber : '.$numSubs.'

'; echo 'Create Date : '.$set['CreateDate'].'

'; ?><? echo '

'; }} ?>



prepare($query); $stmt->execute(); $result= $stmt->fetchAll(); $num_rows= $stmt->rowCount(); } catch(PDOException $e) { die ($e->getMessage().' Back'); } $conn = null; if ($num_rows == 0) { echo '
There are no public list.
';} else { echo '

Public Subscriber List

There are '.$num_rows.' list(s).

'; foreach ($result as $set) { try{ $sql = ' SELECT ls.SubID FROM list_sub ls,user_list ul WHERE ul.UserID=? AND ls.ListID='.$set['ListID'].' AND ls.ListID=ul.ListID '; $stmt = $conn->prepare($sql); $stmt->execute(array($_SESSION['username'])); $numSubs= $stmt->rowCount(); } catch(PDOException $e) { die ($e->getMessage().' Back'); } echo 'List Name : '.$set['ListName'].'

'; echo 'Number of subscriber : '.$numSubs.'

'; echo 'Create Date : '.$set['CreateDate'].'

'; echo ""; echo '

'; }} ?>

这是你想要的吗?

  $("# tags div id ").tabs({ add: function(event, ui) { $(this).append(ui.panel) } }) 

这只是纯粹而简单的标签添加,我认为这就是你要求的。

祝好运。

我已经创建了您在此处描述的问题的最小实现,并且它没有任何问题。 它使用了addTab addTab()函数的经过修改的版本。

我建议您使用古老的Firebug或Chrome内置的开发人员工具来查看正在发生的javascript或其他错误。

另外,尝试简单地升级到最新的jQuery和jQuery-easui库,看看是否有帮助。

Interesting Posts