[EXTENSION] Bootstrap

Houston we have a "Bandwidth Limit Exceeded"

It’s being fixed. Please be patient.

Hello, I’m working with AJAX and I’m running


$this->controller->renderPartial($view, $params, false, true);

With this, the CSS files "Bootstrap" on page being reloaded unnecessarily.

How to solve?

Hello,when i click on any dropdown element class open adds no parent element (<li>), but the current link, and dropdown list not open.

please help

Seems to conflict with the extension TinyMce

Please, help me.

Hi, a little question. Is there a simple way to inset a sign-in form inside of a navbar dropdown? There is an example used outside of Yii (I cannot post links since this is my first post) if you search google for "bootstrap login in dropdown". Should be first result.

Someone posted the same question a few weeks ago. Find my answer here. Don’t forget to set ‘encodeLabel’=>false in TbMenu. Plus the submit button and a few styles and you’ll have it. Cheers.

Usually you have to play around with the 2 boolean parameters for $return and $processOutput. If all this doesn’t help much, check this link: how to manually omit loading css and js files that have already been included by yii. Hope it helps. Cheers.

That’s exactly what I want!

Even had read the link…

The JavaScript files I can prevent them from being loaded.

But CSS files Yii Bootstrap not.

Do you understand what I mean?

So what happens if you do

$this->controller->renderPartial($view, $params, false, false);

instead of ‘false, true’?

This pre-processes the output of the ajax content before sending it to the main view. Of course, in some cases this is counter-dynamic; e.g. when the ajax is part of tabbed content. If it still does not work please post your code (controller, main view, ajax view). Boa sorte, Felipe

Leaving as shown below:


$this->controller->renderPartial($view, $params, false, false);

The files are not loaded on the page unnecessarily.

Perfect! But in my view, I have a new AJAX call, with "ProcessOutput = false", the call is not performed, because the script is not embedded page.

With "ProcessOutput = true", the new call (originating from the renderPartial) is performed, but this ends up happening incorporation of unnecessary scripts like JQuery and Bootstrap.

The JQuery I managed to keep it from being loaded, but need to know how to get the Bootstrap not.

My IndexAction.php:


class IndexAction extends CAction {

    

    public function run() {

        if (Yii::app()->request->isAjaxRequest) {            

            $this->controller->renderPartial('index', null, false, true);

            Yii::app()->end();

        }

        

        $this->controller->render('index');

    }

    

}

The JQuery (and all JS) I managed to make it only be built once the page with the extension nlsclientscript.

Can someone explain how to remove the automatic labels generated by $form->dropDownListRow()?

In post #612, Chris83 said:

I tried this:


<?php echo $form->dropdownlistRow( $model, "account", 

    array(

        "1" => "1",

        "2" => "2",

        "3" => "3",

    ),

    array(

        'label'=>false

    )

); ?>

But, the label is still there.

It’s a little bit tricky to get there. Setting and alternate or no label for form elements is different from setting it for buttons, for instance. Here’s how:


array(

    'labelOptions'=>array('label'=>false),

    'style'=>'display:block; margin-top:10px;', //see comment below

)

As you can see you have to add another array ‘labelOptions’ inside the one for ‘htmlOptions’. Unfortunately, in a vertical-form the label-less drop down will float around the previous form element unless you add the ‘display:block’.

Just in case, depending on the form element ($form->…) there are a couple of options that can be added inside the array for htmlOptions:

arrays: labelOptions, prependOptions, appendOptions, hintOptions, errorOptions, and captchaOptions,

string: hint, prepend, append

All the names are self-explanatory. It may look complicated on first view but it makes perfect sense. Adding additional arrays like that gives you the options to set different styles for all the different elements (label, input, appended input, hint, etc).

Hope it helps.

Nobody owned a solution? = /

Do not know about you, but I find absurd reload all the CSS files whenever a new request is made​​.

Has anyone experienced this problem too?

Hi,

I got a problem. Now, the TbAlert is not automatically closed after several seconds. Is it a normal behavior? or how should I make it automatically closed say after 10 seconds?

Cheers,

Daniel

i like bootstrap. i use it. develop very well

actually i met the same problem long time ago and have to modify the Bootstrap class :




	/**

	 * Initializes the component.

	 */

	public function init()

	{

		// Register the bootstrap path alias.

		if (Yii::getPathOfAlias('bootstrap') === false)

			Yii::setPathOfAlias('bootstrap', realpath(dirname(__FILE__).'/..'));


        //.........................................................................

        // added by yiqing95

        if(Yii::app()->getRequest()->getIsAjaxRequest()){

            //if is ajax mode shouldn't register css and js files again !

            return ;

        }

        //.........................................................................

		// Prevents the extension from registering scripts and publishing assets when ran from the command line.

		if (Yii::app() instanceof CConsoleApplication)

			return;


		if ($this->coreCss !== false)

			$this->registerCoreCss();


		if ($this->responsiveCss !== false)

			$this->registerResponsiveCss();


		if ($this->yiiCss !== false)

			$this->registerYiiCss();


		if ($this->enableJS !== false)

			$this->registerCoreScripts();


        parent::init();

	}




:D

want to listen how others settle this problem !

yiqing95, Thank you for your solution!

To be honest I did not want to change the Core Yii Bootstrap.

But apparently it is the only way to solve the problem agree?

Well, the good news is that solved the problem.

Below is the steps that were made:

I added the extension NLSClientScript to the project.

Adding it, solved the problem with scripts.

Now let’s resolution CSS.

In Bootstrap.php:




// I created a new property.


/**

 * @var boolean to register the Bootstrap in AJAX requests

 * Defaults to true.

 */

public $ajaxCssImport = true;


// And added the following conditional

if(($this->ajaxCssImport && Yii::app()->request->isAjaxRequest) || !Yii::app()->request->isAjaxRequest ) {

    // Prevents the extension from registering scripts and publishing assets when ran from the command line.

    if (Yii::app() instanceof CConsoleApplication)

	    return;


    if ($this->coreCss !== false)

	    $this->registerCoreCss();


    if ($this->responsiveCss !== false)

	    $this->registerResponsiveCss();


    if ($this->yiiCss !== false)

	    $this->registerYiiCss();

}


if ($this->enableJS !== false)

	$this->registerCoreScripts();



In main.php




'bootstrap' => array(

    'class' => 'ext.bootstrap.components.Bootstrap',

    'ajaxCssImport' => false,

),



With that solved my problem.

Anyway you had spoken…


// added by yiqing95

if(Yii::app()->getRequest()->getIsAjaxRequest()){

    //if is ajax mode shouldn't register css and js files again !

    return ;

}

It does not solve the problem.

The CSS files are not loaded, but the AJAX code that is generated by the view that is being called, is not.

So below is outside the conditional parole that I created.


if ($this->enableJS !== false)

	$this->registerCoreScripts();

And adding the extension "NLSClientScript" was necessary because the other JS files, including "bootstrap.js" remained loaded.

Well, that’s it, I was happy to resolve the issue and then let the new amendment as a suggestion for a future version of “Yii Bootstrap”.

Thanks to everyone who helped me troubleshoot.

:lol: i agree , it seems your solution is better !