method script documentation in bbn\Html\Element

Returns the javascript coming with the object

function($with_ele = 1) { $this->update(); $r = ''; if ( isset($this->attr['id']) ){ if ( isset($this->cfg['events']) ){ foreach ( $this->cfg['events'] as $event => $fn ){ $r .= '.'.$event.'('. ( strpos($fn, 'function') === 0 ? $fn : 'function(e){'.$fn.'}' ). ')'; } } if ( isset($this->cfg['widget'], $this->cfg['widget']['name']) ){ $r .= '.'.$this->cfg['widget']['name'].'('; if ( isset($this->cfg['widget']['options']) ){ $r .= '{'; foreach ( $this->cfg['widget']['options'] as $n => $o ){ $r .= '"'.$n.'":'; if ( \is_string($o) ){ $o = trim($o); if ( (strpos($o, 'function(') === 0) ){ $r .= $o; } else{ $r .= '"'.bbn\Str::escapeDquotes($o).'"'; } } else if ( \is_bool($o) ){ $r .= $o ? 'true' : 'false'; } else{ $r .= json_encode($o); } $r .= ','; } $r .= '}'; } $r .= ')'; } if ( !empty($this->help) ){ // tooltip } if ( !empty($r) ){ if ( $with_ele ){ $r = '$("#'.$this->attr['id'].'")'.$r.';'.PHP_EOL; } else{ $r = $r.';'.PHP_EOL; } } } if ( !empty($this->script) ){ $r .= $this->script.PHP_EOL; } if ( \is_array($this->content) ){ foreach ( $this->content as $c ){ if ( \is_array($c) ){ $c = new bbn\Html\Element($c); } if (\is_object($c) && method_exists($c, 'script') ){ $r .= $c->script(); } } } return $r; }

Returns the javascript coming with the object BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way

This website uses cookies to ensure you get the best experience on our website.