Yii Framework Forum: [EXTENSION] Bootstrap - Yii Framework Forum

Jump to content

  • (45 Pages)
  • +
  • « First
  • 3
  • 4
  • 5
  • 6
  • 7
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

[EXTENSION] Bootstrap Bringing together Yii and Twitter Bootstrap Rate Topic: ***** 23 Votes

#81 User is offline   Xuntar 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 18
  • Joined: 19-July 11

Posted 18 January 2012 - 03:37 AM

Hi Chris83,

Is there any reason why this code should not work?

Yii::app()->getClientScript()->registerScript(
	'addManufacturer',
	"function addManufacturer()
	{
		".CHtml::ajax(
			array(
				'url'=>array('manufacturer/create'),
				'data'=> 'js:$(this).serialize()',
				'type'=>'post',
				'dataType'=>'json',
				'success'=>"function(data)
				{
					if (data.status == 'failure')
					{
						$('#addManufacturer div.divLoader').fadeOut(500, function(){
							$('#addManufacturer div.divForForm').html(data.div).fadeIn(500, function(){
								// Here is the trick: on submit-> once again this function!
								$('#addManufacturer div.divForForm form').submit(addManufacturer);
							});
						});
					}
					else
					{
						$('.alert').bootAlert('alert',data.flash.key,data.flash.message);
						$('#addManufacturer div.divForForm').html(data.div);
						$('#addManufacturer').delay(2000).fadeOut(500);
						$('.modal-backdrop').delay(2000).fadeOut(500);
					}
				}",
			)
		)."
	    return false;
	}",
	CClientScript::POS_END
);


I've been following this tutorial http://www.yiiframew...eate-new-model/ about using ajax to create new manufacturers when I'm in my product create view.
Adding them works perfectly, but I cannot use $('#addManufacturer').bootModal('close') or $('.alert').bootAlert(...).
With both of those functions it says "$(...).boot...(...)" is not a function (e.g. "$('#addManufacturer').bootModal('close') is not a function").

Cheers and thank you so much for your extension!


Edit: never mind, I fixed it. It was an issue with dynamically added javascript working in a different scope than your extensions, so it couldn't find them. Changing my code to this works:

Yii::app()->getClientScript()->registerScript(
	'addManufacturer',
	"( function( $ ) {
	$('#addManufacturerLink').click(function(){
		addManufacturer();
		$('#addManufacturer').bootModal('open');
		return false;
	});
	function addManufacturer()
	{
		".CHtml::ajax(
			array(
				'url'=>array('manufacturer/create'),
				'data'=> 'js:$(this).serialize()',
				'type'=>'post',
				'dataType'=>'json',
				'success'=>"function(data)
				{
					if (data.status == 'failure')
					{
						$('#addManufacturer div.divLoader').fadeOut(500, function(){
							$('#addManufacturer div.divForForm').html(data.div).fadeIn(500, function(){
								// Here is the trick: on submit-> once again this function!
								$('#addManufacturer div.divForForm form').submit(addManufacturer);
							});
						});
					}
					else
					{
						$('.alert').bootAlert('alert',data.flash.key,data.flash.message);
						$('#addManufacturer div.divForForm').html(data.div);
						$('#addManufacturer').bootModal('close');
					}
				}",
			)
		)."
	    return false;
	}
} )( jQuery );",
	CClientScript::POS_END
);


The only thing that happens now is that I get 2 "success" messages. It seems like the function is called twice, even though (when I debug the JavaScript) it's not doing that...

Edit: Figured out it's not called twice, but executed twice because jQuery gets registered 2 times. Once when the page is loaded and once when the bootModal form is rendered. I know how to stop all javascript from being rendered in the modal form, but I would like to keep JS validation there. Also it seems that overriding the "run" function of cActiveForm not to include jQuery is not enough... Is there any other place that loads it when BootActiveForm is run?

This post has been edited by Avalon: 19 January 2012 - 02:45 AM

0

#82 User is offline   lhw455 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 9
  • Joined: 17-January 12

Posted 18 January 2012 - 03:52 PM

Thanks avalon, that worked, still figuring this all out!
0

#83 User is offline   Xuntar 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 18
  • Joined: 19-July 11

Posted 18 January 2012 - 04:53 PM

No problem, of course. I can assure you I'm still figuring it all out as well and swearing every now and then along the way ;-)

View Postlhw455, on 18 January 2012 - 03:52 PM, said:

Thanks avalon, that worked, still figuring this all out!

0

#84 User is offline   shaan360 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 22-October 11
  • Location:Pakistan

Posted 27 January 2012 - 05:53 AM

thank you for this great and useful extension. really saving my life
0

#85 User is offline   jmariani 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 53
  • Joined: 12-January 12

Posted 31 January 2012 - 10:11 AM

Awesome extension!

A couple of questions:

1) Are you upgrading to Bootstrap 2.0?
2) How to add dropdowns to dropdowns items in BootNav?

A third one:
In your example of BootNav, the dropdowns stays displayed when I click on the other dropdown. Is this the intended behaviour?

Thank you in advance!
0

#86 User is offline   jmariani 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 53
  • Joined: 12-January 12

Posted 31 January 2012 - 04:52 PM

Hi.

Does anybody have an example of how to use BootActiveForm and the bootfields with CForm?.

Thank you in advance!
0

#87 User is offline   Chris83 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 434
  • Joined: 27-February 10
  • Location:Helsinki, Finland

Posted 01 February 2012 - 11:33 AM

View Postjmariani, on 31 January 2012 - 10:11 AM, said:

Awesome extension!

A couple of questions:

1) Are you upgrading to Bootstrap 2.0?
2) How to add dropdowns to dropdowns items in BootNav?

A third one:
In your example of BootNav, the dropdowns stays displayed when I click on the other dropdown. Is this the intended behaviour?

Thank you in advance!


Yes, I'm going to upgrade to Bootstrap 2.

Bootstrap top-bar does not support dropdowns for dropdown items.

And yes, right now that's the behavior.
Best regards,
Chris

My contribution to the Yii community:
Yiistrap | Auth | Bootstrap | NordCms | Rights | LESS | SEO | Img

Follow me:
Twitter | GitHub | Bitbucket
0

#88 User is offline   bek 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 02-February 12

Posted 02 February 2012 - 08:53 AM

View PostAvalon, on 18 January 2012 - 02:49 AM, said:

Hi, if you put the extension in your extension folder you have to use this:
'bootstrap'=>array(
	'class'=>'application.extensions.bootstrap.components.Bootstrap',
),



hi m8 i have the same problem but even though i tried your proposal it didnt work..
to be more specific here are my files :
main.php
<?php

// uncomment the following to define a path alias
// Yii::setPathOfAlias('local','path/to/local-folder');

// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
return array(
	'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
	'name'=>'MusicBox+',

	
	// preloading 'log' component
	'preload'=>array('bootstrap','log',),
	 // preload the bootstrap component

	// autoloading model and component classes
	'import'=>array(
		'application.models.*',
		'application.components.*',
		'application.extensions.bootstrap.widgets.*',
	),

	'modules'=>array(
		// uncomment the following to enable the Gii tool
		
		'gii'=>array(
			'class'=>'system.gii.GiiModule',
			'password'=>'123',
		 	// If removed, Gii defaults to localhost only. Edit carefully to taste.
			'ipFilters'=>array('127.0.0.1','::1'),
			'generatorPaths'=>array(
			'bootstrap.gii', // since 0.9.1
			),
		),
		
	),

	// application components
	'components'=>array(
		'user'=>array(
			// enable cookie-based authentication
			'allowAutoLogin'=>true,
		),
		// uncomment the following to enable URLs in path-format
		
		'urlManager'=>array(
			'urlFormat'=>'path',
			'rules'=>array(
				'<controller:\w+>/<id:\d+>'=>'<controller>/view',
				'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
				'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
			),
		),
		
		
		'db'=>array(
			'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/aaaa.db',
		),
		// uncomment the following to use a MySQL database
		
		'db'=>array(
			'connectionString' => 'mysql:host=localhost;dbname=aaaa',
			'emulatePrepare' => true,
			'username' => 'root',
			'password' => '',
			'charset' => 'utf8',
		),
		
		'errorHandler'=>array(
			// use 'site/error' action to display errors
            'errorAction'=>'site/error',
        ),
		'log'=>array(
			'class'=>'CLogRouter',
			'routes'=>array(
				array(
					'class'=>'CFileLogRoute',
					'levels'=>'error, warning',
				),
				// uncomment the following to show log messages on web pages
				/*
				array(
					'class'=>'CWebLogRoute',
				),
				*/
			),
		),
		
		'bootstrap'=>array(
        'class'=>'testdrive.protected.extensions.bootstrap.components.Bootstrap',
		),
	),

	// application-level parameters that can be accessed
	// using Yii::app()->params['paramName']
	'params'=>array(
		// this is used in contact page
		'adminEmail'=>'webmaster@example.com',
	),
);


The file that has the error is located in this folder
C:\wamp\www\yii\testdrive\protected\extensions\bootstrap\components\Bootstrap.php
(testdrive is the name of my application)

sorry for my silly question but i've used a lot of combination and i am still facing this stupid error
and i am sure that i'm making something really obvious wrong..

plz help!
0

#89 User is offline   Xuntar 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 18
  • Joined: 19-July 11

Posted 02 February 2012 - 09:15 AM

Did you try using
'class'=>'application.extensions.bootstrap.components.Bootstrap',
instead of
'class'=>'testdrive.protected.extensions.bootstrap.components.Bootstrap',
?

View Postbek, on 02 February 2012 - 08:53 AM, said:

hi m8 i have the same problem but even though i tried your proposal it didnt work..
to be more specific here are my files :
main.php

The file that has the error is located in this folder
C:\wamp\www\yii\testdrive\protected\extensions\bootstrap\components\Bootstrap.php
(testdrive is the name of my application)

sorry for my silly question but i've used a lot of combination and i am still facing this stupid error
and i am sure that i'm making something really obvious wrong..

plz help!

0

#90 User is offline   bek 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 02-February 12

Posted 02 February 2012 - 09:26 AM

View PostAvalon, on 02 February 2012 - 09:15 AM, said:

Did you try using
'class'=>'application.extensions.bootstrap.components.Bootstrap',
instead of
'class'=>'testdrive.protected.extensions.bootstrap.components.Bootstrap',
?


lol it worked..i am new and i thought that "application" should be the application name..
i dont understand how this works..but it does :)

thanks a lot!
0

#91 User is offline   Chris83 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 434
  • Joined: 27-February 10
  • Location:Helsinki, Finland

Posted 02 February 2012 - 02:02 PM

View Postbek, on 02 February 2012 - 09:26 AM, said:

lol it worked..i am new and i thought that "application" should be the application name..
i dont understand how this works..but it does :)

thanks a lot!


You can also use ext instead of application.extensions. It's a shorthand and at least I prefer that.
Best regards,
Chris

My contribution to the Yii community:
Yiistrap | Auth | Bootstrap | NordCms | Rights | LESS | SEO | Img

Follow me:
Twitter | GitHub | Bitbucket
0

#92 User is offline   jmariani 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 53
  • Joined: 12-January 12

Posted 02 February 2012 - 02:31 PM

View PostChris83, on 01 February 2012 - 11:33 AM, said:

Yes, I'm going to upgrade to Bootstrap 2.

Bootstrap top-bar does not support dropdowns for dropdown items.

And yes, right now that's the behavior.

Thank you!
0

#93 User is offline   jmariani 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 53
  • Joined: 12-January 12

Posted 02 February 2012 - 02:59 PM

Hi!

How to add 'condensed' style to BootGridView and BootDetailView?

TIA!
0

#94 User is offline   arunj 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 30-January 12

Posted 02 February 2012 - 05:12 PM

I am new to bootstrap, and fairly new to yii.

I want to know, how can we use properties like span columns in bootstrap plugin.

Also when i render a page, by modifying the layout (main.php) file, when i use BootNav to render the page,
the page is correctly rendered in twitter style, with a twitter like bar at the top, but the main content under it seems to go under it, (i.e. the topbar comes over my main content). Please help in this regard.
0

#95 User is offline   jacmoe 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 2,601
  • Joined: 10-October 10
  • Location:Denmark

Posted 02 February 2012 - 06:12 PM

Set the 'top' property of your body tag to 30px or something, and set it to position: relative IIRC.
It's written in the TB docs.
"Less noise - more signal"
0

#96 User is offline   arunj 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 30-January 12

Posted 02 February 2012 - 06:50 PM

View Postjacmoe, on 02 February 2012 - 06:12 PM, said:

Set the 'top' property of your body tag to 30px or something, and set it to position: relative IIRC.
It's written in the TB docs.


what is TB docs? do you mean Twitter Bootstrap docs?
0

#97 User is offline   jacmoe 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 2,601
  • Joined: 10-October 10
  • Location:Denmark

Posted 02 February 2012 - 07:19 PM

View Postarunj, on 02 February 2012 - 06:50 PM, said:

what is TB docs? do you mean Twitter Bootstrap docs?

Good guess.
Here:
http://twitter.githu...nts.html#navbar

Quote

To make the navbar fixed to the top of the viewport, add .navbar-fixed-top to the outermost div, .navbar. In your CSS, you will also need to account for the overlap it causes by adding padding-top: 40px; to your <body>.

"Less noise - more signal"
0

#98 User is offline   Chris83 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 434
  • Joined: 27-February 10
  • Location:Helsinki, Finland

Posted 05 February 2012 - 03:31 PM

View Postjmariani, on 02 February 2012 - 02:59 PM, said:

Hi!

How to add 'condensed' style to BootGridView and BootDetailView?

TIA!


You can specify the css class for BootGridView just like for CGridView, by giving it in the htmlOptions.
Best regards,
Chris

My contribution to the Yii community:
Yiistrap | Auth | Bootstrap | NordCms | Rights | LESS | SEO | Img

Follow me:
Twitter | GitHub | Bitbucket
0

#99 User is offline   Chris83 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 434
  • Joined: 27-February 10
  • Location:Helsinki, Finland

Posted 07 February 2012 - 12:32 PM

Upgrading this extension to Bootstrap 2 is now almost complete.

I will still need to do some testing but I'm quite confident that the next release will be ready by the end of this week. I will post a link to a demo shortly so that everyone can get a preview of the upcoming changes.

Hang in there! :)
Best regards,
Chris

My contribution to the Yii community:
Yiistrap | Auth | Bootstrap | NordCms | Rights | LESS | SEO | Img

Follow me:
Twitter | GitHub | Bitbucket
0

#100 User is offline   Chris83 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 434
  • Joined: 27-February 10
  • Location:Helsinki, Finland

Posted 07 February 2012 - 02:06 PM

As mentioned above I'm developing the new release for this extension with support for Bootstrap 2.

Here's a working demo with some of the polished and new widgets in the upcoming release:
http://www.cniska.ne...bootstrap/demo/

Enjoy!
Best regards,
Chris

My contribution to the Yii community:
Yiistrap | Auth | Bootstrap | NordCms | Rights | LESS | SEO | Img

Follow me:
Twitter | GitHub | Bitbucket
0

Share this topic:


  • (45 Pages)
  • +
  • « First
  • 3
  • 4
  • 5
  • 6
  • 7
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

3 User(s) are reading this topic
0 members, 3 guests, 0 anonymous users