سؤال

I am using bpopup to display my popup. Interesting thing to note here is that when I click my button, popup appears, but if I re click that button , error comes in my console that Uncaught TypeError: Object [object Object] has no method 'bPopup' . Sometimes popup appears two times, and when I click third time I encounter same error. Here is part of my code :

<html>
  <head>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
    <script type="text/javascript" src="assets/bpopup.js"></script>
    <script type="text/javascript">
    $(document).ready(function() {
    $("#signin").click(function(){
      $("#popup").bPopup({
        loadUrl: "<?php echo site_url().'xyz/signin'?>",
            });

  });
  });
  </script>
  </head>
  <body>
    <div id="popup" style="display:none;"></div>
    <div style="float:right;display:inline-block"><button id="signin">Sign In</button></div>
  </body>

EDIT : I figured out what problem is, when I click sign in , I see there is a new element created with , so Jquery is loaded again and if jQuery is loaded twice then bpopup will not work. Any idea why this script tag is coming ?

هل كانت مفيدة؟

المحلول 2

Problem solved, I was including jQuery again in my sign up form which was loading with pop up, so on twice loading jQuery , bPopup will not work. Thanks guys for your answers

نصائح أخرى

Change the order of script inclusion (you need to include jquery before including your script)

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="assets/bpopup.js"></script>
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top