Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do i add jquery ui date picker, while already working with bootstrap library?

I'm playing around with bootstrap and i was going to add a datepicker to the page using it, but without any success.. So i found the code for a datepicker, using query ui: Datepicker

And tried this in a new html page, and it worked like a charm. However, i now want to use this in the page i was working on, but it seems like there are some conflicts between the different scripts and css files. Is there a way to solve this?

(i have delated the content of the page but left the scripts and links i'm importing)

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Svensk Bridge</title>
        <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
        <link rel="stylesheet" type="text/css" href="../css/bootstrap-responsive.css">
    </head>

    <body>

        <p>Date: <input type="text" id="datepicker" /></p>


        <script type="text/javascript" src="../js/jquery.js"></script>
        <script type="text/javascript" src="../js/bootstrap.js"></script>
        <script type="text/javascript" src="../js/list-function.js"></script>
    </body>
</html>

If i were to import all the files for the jquery ui for the date picker, it won't work.

<html lang="en">
<head>
  <meta charset="utf-8" />
  <title>jQuery UI Datepicker - Default functionality</title>
  <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" />
  <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
  <script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
  <link rel="stylesheet" href="/resources/demos/style.css" />
  <script>
  $(function() {
    $( "#datepicker" ).datepicker();
  });
  </script>
</head>
<body>

<p>Date: <input type="text" id="datepicker" /></p>


</body>
</html>

So, to sum up: Can i implement the jquery ui datepicker into my already existing document? And which scripts and links get prioritized?

Regards, Bill

like image 526
XT_Nova Avatar asked Dec 11 '22 16:12

XT_Nova


2 Answers

I am using Bootstrap with Jquery UI datepicker, the problem must be the order in which you import things. Here my order:

<script type="text/javascript" src="js/jquery-1.8.3.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.10.2.custom.js"></script>
<script type="text/javascript" src="js/bootstrap.js"></script>
<link type="text/css" href="css/jquery-ui-1.10.2.custom.css" rel="stylesheet" />
<link type="text/css" href="css/bootstrap.css" rel="stylesheet" />
like image 179
Samuel Robert Avatar answered Dec 17 '22 22:12

Samuel Robert


You could, but my personal preference would be to add a Bootstrap-style datepicker instead. I've been using this one and it's pretty great. http://www.eyecon.ro/bootstrap-datepicker/

The advantage here is that you don't actually need to include the jQuery UI library for this.

like image 28
FiniteLooper Avatar answered Dec 18 '22 00:12

FiniteLooper