TbModal::init PHP Method

init() public method

Initializes the widget.
public init ( )
    public function init()
    {
        if (!isset($this->htmlOptions['id'])) {
            $this->htmlOptions['id'] = $this->getId();
        }
        if ($this->autoOpen === false && !isset($this->options['show'])) {
            $this->options['show'] = false;
        }
        $classes = array('modal hide');
        if ($this->fade === true) {
            $classes[] = 'fade';
        }
        if (!empty($classes)) {
            $classes = implode(' ', $classes);
            if (isset($this->htmlOptions['class'])) {
                $this->htmlOptions['class'] .= ' ' . $classes;
            } else {
                $this->htmlOptions['class'] = $classes;
            }
        }
        echo CHtml::openTag('div', $this->htmlOptions);
    }

Usage Example

 /**
  * Initializes the widget
  */
 public function init()
 {
     // Generate a unique ID. We can't rely on the built-in counter in
     // CWidget::getId() because these modals may be rendered from AJAX
     // request and the counter will be zero then
     $this->id = uniqid($this->getId());
     parent::init();
     TbHtml::addCssClass('watch-modal', $this->htmlOptions);
     $this->header = Yii::t('Movies', 'Watch / Download');
 }
All Usage Examples Of TbModal::init