Tuesday 11 April 2017

dont work datapicker in my proyect

I'm trying to simulate a SPA application, injecting content into the central block of my page, not to load entire pages on my web. But when I use a datepicker in one of my injections the calendar is not displayed.

I go loading the central content according to the sections of my page that are selected, I upload them to the general.js file, using JQuery.load charge the html and js asociate to the new section of my page.

In index.jade I have the first page (the only one that is loaded) in node.js:

doctype html
  html
   head
meta(http-equiv="Content-Type", content="text/html; charset=utf-8")
meta(http-equiv="X-UA-Compatible", content="IE=edge")
title Planet
base(href='/')
meta(name='viewport', content='width=device-width, initial-scale=1')
link(rel='icon', type='image/x-icon', href='favicon.ico')
//link(id="template-file", href="views/modals.html", rel="import") 
link(href="AdminLTE-2.3.11/dist/css/AdminLTE.min.css", type="text/css", rel="stylesheet")
link(href="AdminLTE-2.3.11/dist/css/skins/_all-skins.min.css", rel="stylesheet")
link(href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css', rel='stylesheet')
link(href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css", rel="stylesheet")
link(href="https://cdnjs.cloudflare.com/ajax/libs/ionicons/2.0.1/css/ionicons.min.css", rel="stylesheet")
script(type='text/javascript', src='https://code.jquery.com/jquery-1.11.3.min.js')
script(type="text/javascript", src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.4.1/js/bootstrap-datepicker.min.js")
link(rel="stylesheet", href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.4.1/css/bootstrap-datepicker3.css")
link(href='css/mis_estilos.css', rel='stylesheet')

script.
  $(document).ready(function(){
  var date_input=$('input[name="date"]'); //our date input has the name "date"
  var container=$('.bootstrap-iso form').length>0 ? $('.bootstrap-iso form').parent() : "body";
  var options={
  format: 'mm/dd/yyyy',
  container: container,
  todayHighlight: true,
  autoclose: true,
  };
  date_input.datepicker(options);
  })

body

.container
  .row
    include ./../public/views/header.html
  br
  br

  .row#bloque_central
    .row#contenido_central


 include ./../public/views/footer.html

footer.html :

<div id="scripts_footer"></div>
 <script 
  src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js">
 </script>
 <script src="../AdminLTE-2.3.11/dist/js/app.min.js"></script>
 <script src="js/general.js"></script>

my new page inyection:

<div class="bootstrap-iso">
<div class="container-fluid">
<div class="row">
<div class="col-md-6 col-sm-6 col-xs-12">

<!-- Form code begins -->
<form method="post">
  <div class="form-group"> <!-- Date input -->
    <label class="control-label" for="date">Date</label>
    <input class="form-control" id="date" name="date" placeholder="MM/DD/YYY" type="text"/>
  </div>
  <div class="form-group"> <!-- Submit button -->
    <button class="btn btn-primary " name="submit" type="submit">Submit</button>
  </div>
 </form>
 <!-- Form code ends --> 

</div>
</div>    
</div>
</div>

I have already tried several things like initialize the datepicker in the js of the new section, but it still does not show up



via Jesús Ortega Mateu

No comments:

Post a Comment