JQuery elements only work after page refresh

I am building a Reacts based application, I have several jquery elements on the page, such as the JqueryUI date picker and bootstraps tooltip.

The problem is that these favorites do not work until I reload the page.

This way its, like jQuery scripts, not loaded for the first time.

I looked at the console and do not see any jQuery / javascript related errors.

Any help would be greatly appreciated. here is my index.html page

<!doctype html>
<html class="no-js" lang="">
  <head>
      <meta charset="utf-8">
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <meta name="description" content="">
      <meta name="viewport" content="width=device-width">

      <title>ICETEA</title>

      <!-- Latest compiled and minified JavaScript -->
      <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>

      <script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>

      <!-- JQuery UI JS - Used for the datepicker -->
      <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>

      <!-- Bootstrap theme -->
      <link href="//netdna.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" rel="stylesheet">

      <link rel="stylesheet" href="/css/main.css">
      <!-- JQuery UI CSS - Theme: Blitzer, used for the datepicker -->
      <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/themes/blitzer/jquery-ui.css">

  </head>
  <body>

    <div id="app"></div>

    <script src="/js/main.js"></script>

    <script>
      $(document).ready(function(){
          $('[data-toggle="tooltip"]').tooltip();
      });
    </script>

    <script>
      $(function() {
        $( "#datepicker" ).datepicker();
        $( "#datepicker" ).change(function() {
          $( "#datepicker" ).datepicker( "option", "dateFormat", "DD d MM" );
        });
      });
    </script>

  </body>
</html>
+4
source share
1 answer

, , . , , ; , , .

@vanburen , , . jQuery, Bootstrap. , :

: Bootstrap JavaScript jQuery ( ) @bootstrap.min.js: 6

CSS , JavaScript.

: . , .

+2

Source: https://habr.com/ru/post/1612787/


All Articles