Welcome Guest, Not a member yet? Register   Sign In
using helpers outside the systems folder
#4

[eluser]JulianM[/eluser]
I like this idea. Thanks.

I was using a different approach, but I think I will change for this approach. Before, I was using a <a href="&lt;?php echo site_url() ?&gt;ajax.php" id="ajax"> in the view and then in the javascript file (jQuery) I did something like this: $('ajax').attr('href') to retrieve the ajax function to use.


[quote author="inparo" date="1220339580"]I usually have a general javascript view that defines an object literal with a few constants. Just put that in front of all your other scripts.
Code:
&lt;/script type="text/javascript"&gt;
    &lt;!--
        var CI = {
            'base_url': '&lt;?php echo site_url(); ?&gt;/',
            'blab': '&lt;?php echo $something_my_js_needs; ?&gt;'
        };
    //--&gt;
&lt;/script&gt;
Then, to call a url:
Code:
var url = CI.base_url + 'some/url/goes/here';
[/quote]


Messages In This Thread
using helpers outside the systems folder - by El Forum - 08-31-2008, 10:33 AM
using helpers outside the systems folder - by El Forum - 09-01-2008, 07:37 PM
using helpers outside the systems folder - by El Forum - 09-01-2008, 08:13 PM
using helpers outside the systems folder - by El Forum - 09-29-2008, 06:44 PM



Theme © iAndrew 2016 - Forum software by © MyBB