How can I include jQuery and bootstrap libraries in codeigniter? I am new with codeigniter , tried to watch some videos in youtube , but nothing , thank u
-
3Possible duplicate of include css js in view page of codeigniterWoodrow– Woodrow2017-05-18 21:16:42 +00:00Commented May 18, 2017 at 21:16
-
Have you try to use 'em in reqular html file?Ukasha– Ukasha2017-05-19 02:50:18 +00:00Commented May 19, 2017 at 2:50
-
Have you set your base_url in config.php?ImBhavin95– ImBhavin952017-05-19 10:33:42 +00:00Commented May 19, 2017 at 10:33
2 Answers
Here's what you can do:
First be sure to have installed and working CodeIgniter framework, first you have to see the "Welcome page" of the framework, and you have to get downloaded the files of jQuery and Bootstrap. After this, you have to create your view for example 'home.php' file in the application/views folder.
Then try to show a view with HTML code in the browser, in your main controller place the next lines:
class Inicio extends CI_Controller { public function __construct() { parent::__construct(); }// public function index() { $this->load->view('home'); // The final path file of the view is application/views/home.php } }In your view file (home.php) you have to call the needed files to load jQuery and Bootstrap, for example:
<!DOCTYPE html> <html lang="es"> <head> <meta charset="utf-8" /> <base href="http://yourdomain.com/"> <!-- Bootstrap --> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <script src="bootstrap-3.3.5-dist/js/bootstrap.min.js"></script> <link rel="stylesheet" href="bootstrap-3.3.5-dist/css/bootstrap.css"> <!-- jQuery --> <script src="js/jquery-2.1.1.js"></script> </head>After this if your paths are correct, the files will be loaded.
So I recommend to you to read the starter tutorial of CodeIgniter (click here) and you can experiment with controllers and views first.
The paths of jQuery and Bootstrap may vary depending the version you've downloaded.
Comments
add the following scripts and link in your view file.
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
please visit this link