CakePHP + jQuery.notifyBar

Ang notifyBar ay ginagamit upang magbigay ng impormasyon sa user. Tulad halimbawa pagtapos ng pagsave, sasabihin ng web application sa user kung ito ay matagumpay o may error.

Ipapakita dito kung paano i-setup at paggamit ng jQuery.notifyBar sa Session->flash() ng CakePHP.

Mga kailangan

Setup

Hakbang 1: Pumunta sa folder ng cakephp application. Gumawa ng file sa app/views/element/notify_bar.ctp.

Hakbang 2: Ilagay ang sumusunod na code

<?php
$default = array(
	'cls' => '',
	'close' => true,
	'delay' => 2000,
	'animationSpeed' => 'normal',
);
extract($default, EXTR_SKIP);
ob_start();
?>
$(function () {
	$.notifyBar({
		html: "<?php echo $message;?>",
		cls: "<?php echo $cls; ?>",
		close: "<?php echo $close; ?>",
		delay: <?php echo $delay; ?>,
		animationSpeed: "<?php echo $animationSpeed; ?>"
	});
});
<?php echo $this->Javascript->codeBlock(ob_get_clean()); ?>

Gamit

Sa inyong controller, maaari kayong mag pasa ng argument sa $this->Session->setFlash() tulad ng halimbawang ito:

if ($success) {
  $this->Session->setFlash('Iyong mensahe', 'notify_bar');
}

Maaari ding mag-pasa ng params sa notify_bar elements katulad ng pagpasa ng params sa jQuery.notifyBar. Halimbawa:

if ($success) {
  $this->Session->setFlash('Matagumpay na mensahe', 'notify_bar', array('cls' => 'success'));
} else {
  $this->Session->setFlash('May error na mensahe', 'notify_bar', array('cls' => 'error'));
}

Pagsasaayos

Mga iba pang params na maaaring i-set.

  • cls – class
  • close – kung mayroong close link
  • delay – kung gaano katagal magview ang notify sa milisegundo
  • animationSpeed – kung gaano kabilis ang animation, mga pagpipilian: ‘normal’, ‘slow’, ‘fast’

2 Tugon tungo sa “CakePHP + jQuery.notifyBar”

  1. foobarph ay nagsabing:

    base!

    para saan ang notifybar?

    • tristan622 ay nagsabing:

      Ang notifyBar ay ginagamit upang magbigay ng impormasyon sa user. Tulad halimbawa pagtapos ng pagsave, sasabihin ng web application sa user kung ito ay matagumpay o may error.

Mag-iwan ng Tugon

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Palitan )

Twitter picture

You are commenting using your Twitter account. Log Out / Palitan )

Facebook photo

You are commenting using your Facebook account. Log Out / Palitan )

Connecting to %s


Follow

Get every new post delivered to your Inbox.