Welcome Guest, Not a member yet? Register   Sign In
include javascript in CI4 view
#6

(11-11-2024, 11:33 PM)Hi Sir, thank you for your input! What I have done, added a script tag in view file like Wrote:
Code:
<script src="<?=base_url()?>js/encomendas/dtArtigos.js"></script>


In the js file just for testing I wrote

PHP Code:
<?php 
 $c 
config('Ncweb');
?>

var testvar = 'Hi';
alert(testvar); 

And got javascript error in the dev tools of browser Uncaught SyntaxError: expected expression, got '<'

Funny enought, the $c = config('Ncweb') just works in the view file, but not in the js file. In CI3 I had no problem in accessing $this-config->item('ccc') and produce javascript according



InsiteFX
PHP Code:
// Get shared instance with config function
$settings config('configFileName'); 
Reply


Messages In This Thread
include javascript in CI4 view - by jcarvalho - 11-11-2024, 09:15 AM
RE: include javascript in CI4 view - by warcooft - 11-11-2024, 10:46 AM
RE: include javascript in CI4 view - by jcarvalho - 11-11-2024, 11:06 AM
RE: include javascript in CI4 view - by InsiteFX - 11-11-2024, 11:33 PM
RE: include javascript in CI4 view - by jcarvalho - 11-12-2024, 03:42 AM
RE: include javascript in CI4 view - by InsiteFX - 11-12-2024, 04:02 AM
RE: include javascript in CI4 view - by jcarvalho - 11-12-2024, 07:31 AM
RE: include javascript in CI4 view - by InsiteFX - 11-12-2024, 11:00 PM



Theme © iAndrew 2016 - Forum software by © MyBB