Bootstrap Jquery Integration Into Yii

hii guys ,

I am new to yii framework… so if u can help me with the following problem i would be grateful.

I have this all UI with the help of twitter-bootstrap complete. Now i want to integrate it into yii framework .

while integrating this a problem with jquery has occured.My UI without framework works fine. with all the script tags as follows

[html]<script src="<?php Yii::app()->request->baseUrl?>/assests/js/navigation.js"></script>

&#60;script src=&quot;&lt;?php Yii::app()-&gt;request-&gt;baseUrl?&gt;/assests/js/bootstrap/bootstrap-affix.js&quot;&gt;&lt;/script&gt;


&#60;script src=&quot;&lt;?php Yii::app()-&gt;request-&gt;baseUrl?&gt;/assests/js/bootstrap/bootstrap-alert.js&quot;&gt;&lt;/script&gt;


&#60;script src=&quot;&lt;?php Yii::app()-&gt;request-&gt;baseUrl?&gt;/assests/js/bootstrap/bootstrap-tooltip.js&quot;&gt;&lt;/script&gt;


&#60;script src=&quot;&lt;?php Yii::app()-&gt;request-&gt;baseUrl?&gt;/assests/js/bootstrap/bootstrap-dropdown.js&quot;&gt;&lt;/script&gt;


&#60;script src=&quot;&lt;?php Yii::app()-&gt;request-&gt;baseUrl?&gt;/assests/js/bootstrap/bootstrap-tab.js&quot;&gt;&lt;/script&gt;


&#60;script src=&quot;&lt;?php Yii::app()-&gt;request-&gt;baseUrl?&gt;/assests/js/bootstrap/bootstrap-button.js&quot;&gt;&lt;/script&gt;


&#60;script src=&quot;&lt;?php Yii::app()-&gt;request-&gt;baseUrl?&gt;/assests/js/bootstrap/bootstrap-collapse.js&quot;&gt;&lt;/script&gt;


&#60;script src=&quot;&lt;?php Yii::app()-&gt;request-&gt;baseUrl?&gt;/assests/js/bootstrap/bootstrap-fileupload.js&quot;&gt;&lt;/script&gt;


&#60;script src=&quot;&lt;?php Yii::app()-&gt;request-&gt;baseUrl?&gt;/assests/js/bootstrap/bootstrap-inputmask.js&quot;&gt;&lt;/script&gt;


&#60;script src=&quot;&lt;?php Yii::app()-&gt;request-&gt;baseUrl?&gt;/assests/js/select2/select2.min.js&quot;&gt;&lt;/script&gt;


&#60;script src=&quot;&lt;?php Yii::app()-&gt;request-&gt;baseUrl?&gt;/assests/js/bootstrap/bootstrap-tagmanager.js&quot;&gt;&lt;/script&gt;


&#60;script src=&quot;&lt;?php Yii::app()-&gt;request-&gt;baseUrl?&gt;/assests/js/bootstrap/bootstrap-typeahead.js&quot;&gt;&lt;/script&gt;


&#60;script src=&quot;&lt;?php Yii::app()-&gt;request-&gt;baseUrl?&gt;/assests/js/jquery.form.js&quot;&gt;&lt;/script&gt;

<script>

       &#036;('.demoTabs a').click(function (e) {


				e.preventDefault();


				&#036;(this).tab('show');


			})

</script>[/html]

when i use the same with yii using the script tags the jquery wasnt functional …(jquery tabs in my case).I have heard the a script should be registered before using it . but wasnt able to follow the usage properly . So i need help with this integration problem. That is how to register scripts instead of using <script tags>

Thank you …

Try this


Yii::app()->clientScript->registerCoreScript('jquery');

thanks for the response…

Is that for jquery library … if yes then how to register other js files and inline scripts…

I downloaded the zip file from the site choosing all the components

and extracted in assets folder as bootstrap.

The following two lines will register the all the 13 javascript plugins and necessary css in a view.




<?php

Yii::app()->clientScript->registerScriptFile("assets/bootstrap/js/bootstrap.min.js");

Yii::app()->clientScript->registerCssFile("assets/bootstrap/css/bootstrap.min.css");

?>



Now I can use the bootstrap-tab.js in the following way.




<ul class="nav nav-tabs" id="myTab">

<li class="active"><a href="#home">Home</a></li>

<li><a href="#profile">Profile</a></li>

<li><a href="#messages">Messages</a></li>

<li><a href="#settings">Settings</a></li>

</ul>


<div class="tab-content">

<div class="tab-pane active" id="home">...</div>

<div class="tab-pane" id="profile">...</div>

<div class="tab-pane" id="messages">...</div>

<div class="tab-pane" id="settings">...</div>

</div>


<?php 

Yii::app()->clientScript->registerScript('tabtest','

    $("#myTab a").click(function (e) {

    e.preventDefault();

    $(this).tab("show");

    })

'

);



Thanks for the reply…

I have a layout file which has the following code


	Yii::app()->clientScript->registerScriptFile(Yii::app()->getBaseUrl() ."/js/bootstrap.min.js");

		Yii::app()->clientScript->registerCssFile(Yii::app()->getBaseUrl()."/css/bootstrap.min.css");


Yii::app()->clientScript->registerScript('jquery-one',

				' $(document).ready(function(){

				

				

				$("#myTab a").click(function (e) {

					e.preventDefault();

					$(this).tab("show");

				});

				

				// Tooltips

				$("[title]").tooltip({

					placement: \'top\'

				});

				

				// Dropdowns

				$(".dropdown-toggle").dropdown();

				

				// Tabs

				

				// Smart Wizard

				$("#wizard").smartWizard();

			});' ,

				CClientScript::POS_HEAD);

I have used the tabs in the view file as follows

[html]<div class="tabbable">

			&lt;ul class=&quot;nav nav-tabs&quot; id=&quot;myTab&quot;&gt;


				&lt;li class=&quot;active&quot;&gt;&lt;a href=&quot;#tab1&quot; data-toggle=&quot;tab&quot;&gt;Basic Info&lt;/a&gt;


				&lt;/li&gt;


				&lt;li&gt;&lt;a href=&quot;#tab2&quot; data-toggle=&quot;tab&quot;&gt;Courses you tech&lt;/a&gt;&lt;/li&gt;


				&lt;li&gt;&lt;a href=&quot;#tab3&quot; data-toggle=&quot;tab&quot;&gt;Job Preferences&lt;/a&gt;&lt;/li&gt;


				&lt;li&gt;&lt;a href=&quot;#tab6&quot; data-toggle=&quot;tab&quot;&gt;Course Details&lt;/a&gt;&lt;/li&gt;


				&lt;li&gt;&lt;a href=&quot;#tab4&quot; data-toggle=&quot;tab&quot;&gt;Background&lt;/a&gt;&lt;/li&gt;


				&lt;li&gt;&lt;a href=&quot;#tab5&quot; data-toggle=&quot;tab&quot;&gt;Contact Adress&lt;/a&gt;&lt;/li&gt;


				&lt;li&gt;&lt;a href=&quot;#tab7&quot; data-toggle=&quot;tab&quot;&gt;Upload Resume&lt;/a&gt;&lt;/li&gt;


			&lt;/ul&gt;


			&lt;div class=&quot;tab-content&quot; style=&quot;padding: 0;&quot;&gt;


				&lt;div class=&quot;tab-pane active&quot; id=&quot;tab1&quot;&gt;...&lt;/div&gt;

for all the tabs

[/html]

Is there any error in code because the tabs arent working