codeigniter with knockoutjs |
[eluser]chubbypama[/eluser]
hi. i'm trying to incoporate knockoutjs into my ci app. right now, i'm just trying to do a simple test. in one of my views, i want to create some controls that are bound to values defined in my viewModel in javascript. the page fails when it comes to displaying the data bound fields with an error that "ko" is not defined. I'm wondering if it's because my include file is not being picked up. with CI, can i do something like this in my view: Code: <html> It seems like the editor in this forum removes any javascript tags... but basically before the body ends, i have a script tag to include the knockoutjs file. the src property is set to "js/knockout.x.x.js". ko is defined in this js file. I've create my js folder in the same folder as the actual view. so for example: c:\wamp\www\myapp\application\views\myview\js> is this ok?
[eluser]weboap[/eluser]
.htaccess won't let you access the js files where you have them now follow @InsiteFX file structure: http://ellislab.com/forums/viewthread/217657/
[eluser]chubbypama[/eluser]
[quote author="weboap" date="1337795798"].htaccess won't let you access the js files where you have them now follow @InsiteFX file structure: http://ellislab.com/forums/viewthread/217657/[/quote] Thanks. I read that post...and i did the following: 1. specified a base url in my config.php 2. loaded the url helper in my controller's constructor 3. moved my js folder to c:\wamp\www\myapp\js 4. changed the [removed] tag's src to be src='<?php echo base_url();?>js/knockout.x.x.x.js' That seems to have fixed the problem. But what if i want to have a js file folder per view? is that bad design? for example if i have the following directory structure: c:\wamp\www\myapp\application\views\myview1> c:\wamp\www\myapp\application\views\myview2> c:\wamp\www\myapp\application\views\myview3> If i wanted to, could i create my views & viewModels(knockoutjs view/viewModels) and then save them in each view's respective folder like...: c:\wamp\www\myapp\application\views\myview1\js\view1customjs.js c:\wamp\www\myapp\application\views\myview2\js\view2customjs.js c:\wamp\www\myapp\application\views\myview3\js\view3customjs.js Thanks. |
Welcome Guest, Not a member yet? Register Sign In |