Welcome Guest, Not a member yet? Register   Sign In
How do I insert Javascript in CI?
#2

[eluser]davidbehler[/eluser]
Basically you got two options:

1. You can add a "[removed][removed]" tag to your view and insert your js function there or
2. Put your function in a js file and include that file in your view using "[removed][removed]"

If the code of your function depends on the data that was loaded, e.g. the id of an element you work on, then you can't put it in a js file but have to put it in your view and fill all the parts that are variable using <?=?>.

Correct me if I am wrong, but that's what I have been doing so far and I could not come up with anything else that seemed more appropriate. (Except that you can create your js code in the controller and give it to the view file using the $data array)


Messages In This Thread
How do I insert Javascript in CI? - by El Forum - 07-07-2008, 03:59 AM
How do I insert Javascript in CI? - by El Forum - 07-07-2008, 04:18 AM
How do I insert Javascript in CI? - by El Forum - 07-07-2008, 07:55 PM



Theme © iAndrew 2016 - Forum software by © MyBB