在WordPress中显示带有PHP插件的弹出窗口

时间:2018-12-29 22:25:51

标签: php html wordpress

我是插件创建的新手,我正在尝试编写WordPress插件的代码,该插件将一个按钮添加到帖子页面,然后在单击时应显示带有项目列表的PopUp。这些项目应该是可单击的,并且在单击一项后,弹出窗口应该关闭。问题是我尝试使用模式进行操作,但是只要我单击任何按钮或菜单项(而不是弹出窗口),它就会显示第二秒钟的列表,而不仅仅是我添加的按钮,如果我单击按钮,它不会t显示一个PopUp窗口,而是将我重定向到带有后缀post.php的新页面。 这是我的代码:`

add_action('add_meta_boxes', 'add_your_meta_box'); 

    function add_your_meta_box(){
        add_meta_box('table-metabox', 'Bookmaker Table', 'function_of_metabox', 'post', 'normal', 'low');
    }

    function function_of_metabox() {
        $jsonObj = getContent(0);
        ?>
            <button class="btn btn-primary btn-lg" data-toggle = "modal" data-target"$myModal">Select Game</button>
            <!--<input type="submit" class="button button-primary button-large" value="Select Game" id="add-table"/> -->
        <?php }

这是应该作为弹出窗口打开的模式:

<!DOCTYPE html>
<html>
<head>
<title>Proyecto TI | Sube imágenes</title>
<style type="text/css">
    .content ul li {
    display:block;
    list-style:none;
    padding:5px 10px 5px 15px;
}
</style>
</head>
<body>
<!-- Modal -->
<div class = "modal fade" id = "myModal" tabindex = "-1" role = "dialog" 
   aria-labelledby = "myModalLabel" aria-hidden = "true">

   <div class = "modal-dialog">
      <div class = "modal-content">

         <div class = "modal-header">
            <button type = "button" class = "close" data-dismiss = "modal" aria-hidden = "true">
                  &times;
            </button>

            <h4 class = "modal-title" id = "myModalLabel">
               Select a Game
            </h4>
         </div>

         <div class = "modal-body">
            <ul>
                <li onClick ="sendID">Der Bums aus der Json</li>
            </ul>
         </div>

         <div class = "modal-footer">
            <button type = "button" class = "btn btn-default" data-dismiss = "modal">
               Close
            </button>

            <button type = "button" class = "btn btn-primary">
               Submit changes
            </button>
         </div>

      </div><!-- /.modal-content -->
   </div><!-- /.modal-dialog -->

</div><!-- /.modal -->
</body>
</html>

`感谢您提出的任何宝贵意见,请帮我解决这个问题。

0 个答案:

没有答案