where i add script function…?
fun:
$('#mycalendar2').monthly({
mode: 'picker',
target: '#mytarget',
setWidth: '250px',
startHidden: true,
showTrigger: '#mytarget',
stylePast: true,
disablePast: true
});
where i add script function…?
fun:
$('#mycalendar2').monthly({
mode: 'picker',
target: '#mytarget',
setWidth: '250px',
startHidden: true,
showTrigger: '#mytarget',
stylePast: true,
disablePast: true
});
this is what i am doing css and js
echo $this->Html->css(array(‘font’));
echo $this->Html->script(array(‘scripts’));
You can write this function in scrip block
// In bottom your view
<?php $this->start('scriptBottom'); ?>
<script>
$(function () {
$('#mycalendar2').monthly({
mode: 'picker',
target: '#mytarget',
setWidth: '250px',
startHidden: true,
showTrigger: '#mytarget',
stylePast: true,
disablePast: true
});
});
</script>
<?php $this->end(); ?>
In default.ctp before close </ body>
// In your layout
<?= $this->fetch('scriptBottom') ?>
</body>
</html>
for this answer, you can read this document, very clear example
this is my header file
$this->start(‘scriptBottom’); ?>
<?php $this->end(); ?>src/Template/User/home.ctp
<?= $this->fetch('scriptBottom') ?>what i did wrong…?
but its not working
anyone help me…
$this->Html->scriptStart([‘block’ => true]);
echo “alert(‘I am in the JavaScript’);”;
$this->Html->scriptEnd();?>
is working but how to add functions instead of alert message
your code is missing
<?php $this->start('scriptBottom'); ?>
<script>
... javascrtip code here.
</script>
<?php $this->end(); ?>
and put scriptBottom before closed body not in header.
because all JS function located after call jquery file.
// In your layout
<?= $this->fetch('scriptBottom') ?>
</body>
</html>
<script>
… javascrtip code here.
<?php $this->end(); ?>
what filename under that ill put that code…?
above three files i am using
header.ctp :- for template header(like meta tage, $this->Html->css();, $this->Html->js())
mylayout.ctp:-
<?php echo $this->element('header'); echo $this->fetch('content'); ?> <?= $this->fetch('scriptBottom') ?>home.ctp:- (for template body tag)
what i did wrong jquery and js are not linking only css is linking
please help me…
regards,
Darshan
You should do like this…
i putted default.ctp like this
I think, battter your make sure all css and js loaded before used element.