简体   繁体   English

如何强制使用PHP打开Jquery Mobile弹出窗口?

[英]How do you force a Jquery Mobile popup to open using php?

Basically, I am trying to force one of my Jquery mobile popups to open up when isset($_POST["submit"]) is triggered. 基本上,我试图在触发isset($ _ POST [“ submit”])时强制打开我的Jquery移动弹出窗口之一。

Note that having the popup load on page load will not work in this situation, it must be activated when the form is submitted. 请注意,在这种情况下无法在页面上加载弹出窗口,因此在提交表单时必须将其激活。

For example: 例如:

<?php
if(isset($_POST['submit']))
{ 
      //other stuff
      //force open popup
}
?>
<form method='post' action='self.php'>
   <input type='submit' name='submit' value='submit' />
</form>
<a href="#popup" data-rel="popup" data-position-to="window" data-role="button" data-inline="true" data-icon="check" data-theme="a" data-transition="pop">popup</a>
<div data-role="popup" id="popupLogin" data-theme="a" class="ui-corner-all">
    <!-- Popup contents -->
</div>

Thanks in advanced! 提前致谢!

Can you try this one ?? 你能试试这个吗?

<script type="text/javascript">
 $('#form').on('submit', function () {
    $("#popupLogin").popup("open")
  });
</script>

Credits to Omar thanks for correcting me :) 感谢Omar,感谢您对我的纠正:)

Can you not just echo something to make the popup appear, or if it's the a that opens it normally you can simulate a click on it... 你能不只是呼应的东西,使弹出出现,或者如果它是a通常打开它,你可以模拟它的点击...

<?php
if(isset($_POST['submit']))
{ 
    //other stuff
?>
<script type="text/javascript">
$("document").ready(function(){
    // Simulate a click on a. I'd recommend giving A an ID or class to get it.
    $("a[href=#popup]").click();
});
</script>

<?php
}
?>
Add id to anchor tag and use its click event when posted. Code below: 

    <form method='post' action='self.php'>
       <input type='submit' name='submit' value='submit' />
    </form>
    <a id="popUp" href="#popup" data-rel="popup" data-position-to="window" data-role="button" data-inline="true" data-icon="check" data-theme="a" 
    <div data-role="popup" id="popupLogin" data-theme="a" class="ui-corner-all">
        <!-- Popup contents -->
    </div>
<?php
    if(isset($_POST['submit']))
    { 
          //other stuff
          //force open popup
          echo "<script>";
          echo "$('#popUp').click();"
          echo "</script>";
    }
    ?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM