Welcome Guest, Not a member yet? Register   Sign In
Javascript deprecated
#1

(This post was last modified: 11-05-2017, 11:22 AM by JeffreyB.)

Probably some dumb questions from a noob, but I am attempting to use javascript and jquery.

1) Loading as a library in my one of my controller files,

$this->load->helper(array('url', 'html',));
$this->load->library('session');

works.

$this->load->library('jquery');

and other permutations like /javascript/jquery/  etc etc return Error Unable to Load but when I use the autoload.php function, as

$autoload['libraries'] = array('Javascript');

it works. Have I just not hit the right syntax or am I actually loading something I dont know about, or is my logging not telling me the right info?? (Actually, the logging says 'Javascript Class Initialized and loaded. Driver used: jquery.)

2) The CI User_Guide says javascript class is deprecated. Does this mean I am not supposed to use any java at all? Or is it the documentation is faulty and? I do not understand this.

Thanks for any help.
Reply
#2

I may be missing something here, but jquery is a browser side javascript library, that you load onto your page with some html in the footer, just like a css file in the header. CI does not 'use' jquery. CI does not care what you output to your users browser, and does not care what your user uses or experiences on your page. JavaScript does not run on your server, where your CI is sitting and executing.

Just put the relevant links to your js files and css files into your header view or footer view. It has nothing to do with CI. In the same way you would not load an image into CI to use in a page, you would just output the link to the image and display it however you want.

Have I missed or misunderstood something in your question?

Paul.
Reply
#3

(This post was last modified: 11-05-2017, 07:08 PM by JeffreyB.)

Thanks for the prompt reply Paul, and my apologies for not really understanding what I am doing.

From your reply, I believe what you are saying is

1) I have to "point" or "load" my jquery library
2) I would do this in a footer or header, just like I would point or load CSS or load an image.

If this is correct, then what I am asking is:

1) Why am I using a framework when I have to point and load all my CSS and variables and more for every page? Is this not what CI is for, to take out the redundancy of retyping and retyping? Or am I confusing CI for something like a page template, like the Blade templates in Laravel?
2) That said, what I am trying to do, I think, is actually point or load my Jquery, which is what I think you are also trying to tell me to do. I can load this in every view. Is there a way to pre-load in a controller or ??

My directory tree is:

application
assets
 - css
     -- nothing here (meaning there is no style.css or any other files)
 - js
     -- jquery (which I copied from the original file and renamed it)
     -- jquery-10.10.2 (the file I downloaded)  

system
  - libraries
    -- Javascript
       --- Jquery (I think this came with my original CI install)

The whole point of this exercise is I am trying to setup a form and this seems the way most of the online tutorials are doing it. Of course, as usual, code examples are buggy Smile and I am not the brightest bulb on the Christmas tree, but I am still at it. Smile
Reply
#4

FYI - here is how I dealt with your issue ... https://github.com/jedi-academy/package-caboose
Reply
#5

(11-05-2017, 06:07 PM)ciadmin Wrote: FYI - here is how I dealt with your issue ... https://github.com/jedi-academy/package-caboose

Well, I am having enough trouble figuring out why my jquery or whatever it is my helpful tutorials are trying to explain to me (even when I copy code verbatim it still does not work and error messages thrown are not helpful because I don't know enough about debugging)so now, adding another helpful thingie at this point is just sending me down another rabbit hole.

No offense, but I am trying to avoid more widgets until I know the basics. At this point, maybe just writing a style.css file just so I can get a form to look right is my best bet. (I also edited my post above regarding the directory tree - there is no file at all in my css directory as I thought styling was what my javascript jquery was looking after. Maybe I need an extra file or something in the js or in the css directories, or an extra pointer someplace?

Meanwhile, my second question is "why in the CI User Guide is the Javascript class deprecated?" Am I misunderstanding what is being said there?

Thanks all
Reply
#6

(This post was last modified: 11-05-2017, 10:20 PM by ChicagoPhil.)

(11-05-2017, 07:25 PM)JeffreyB Wrote:
(11-05-2017, 06:07 PM)ciadmin Wrote: FYI - here is how I dealt with your issue ... https://github.com/jedi-academy/package-caboose

Well, I am having enough trouble figuring out why my jquery or whatever it is my helpful tutorials are trying to explain to me (even when I copy code verbatim it still does not work and error messages thrown are not helpful because I don't know enough about debugging)so now, adding another helpful thingie at this point is just sending me down another rabbit hole.

No offense, but I am trying to avoid more widgets until I know the basics. At this point, maybe just writing a style.css file just so I can get a form to look right is my best bet. (I also edited my post above regarding the directory tree - there is no file at all in my css directory as I thought styling was what my javascript jquery was looking after. Maybe I need an extra file or something in the js or in the css directories, or an extra pointer someplace?

Meanwhile, my second question is "why in the CI User Guide is the Javascript class deprecated?" Am I misunderstanding what is being said there?

Thanks all

The Javascript Library is deprecated because you do not need to load Jquery from php and it was experimental.
The user guide says to load the library like this:  $this->load->library('javascript/jquery')

Code:
$this->load->library('javascript');
$this->load->library('javascript/jquery');


You should consider just linking Jquery in your view file.
Reply
#7

There were too many divergent & conflicting ideas on what support CI should have for Javascript, which is client-side, so we decided to drop the library rather than continue to fight about it Undecided

The same reasoning is why there is no authentication, ORM, or shopping cart - it is impossible to make everyone happy.

Developers are free to incorporate third-party addins of their liking to handle these.
Reply
#8

Ah, this helps.

No offense to Chicagophil and again, maybe I did not understand what he was saying, but I understood his comment to be, "go ahead and use it anyway, and this is the way to do it." Nothing wrong with this at all, but perhaps CI could look at maybe more explanation in the UserGuide regarding the deprecation.

I thought Javascript/Jquery is a big part of the present day internet. I have no problem with it not being in the CI framework, but as a noob, anything not explained well, or not explained at all, just sends up red flags. If only in this case, because I thought Jquery is so big.

Now I understand your pointer to caboose.

Your post raises another question: I decided to try CI because I was having difficulty with the highly rated Laravel. There, I found it is just getting into so much detail that it is really no longer a light-weight framework, but a good framework that comes with a steep learning curve.

At this stage of the game, CI fits my needs in being able to pass on what I learn to people beside me. If it gets too hard for me to understand what is going on, well, maybe our people will be spending half their time in school (good for BCIT) and the rest of their time actually doing something productive. 

A big item that brought me to both Laravel originally and now CI is built in (I think it is anyway)  csrf. I haven't found a snap-your-finger implementation so decided I would try frameworks which do this. So, sorry for the length of this post, but, you mention "authentication" as non-existent. Is this meaning I should be looking elsewhere for implementing csrf?
Reply
#9

(11-05-2017, 10:50 PM)JeffreyB Wrote: Ah, this helps.

No offense to Chicagophil and again, maybe I did not understand what he was saying, but I understood his comment to be, "go ahead and use it anyway, and this is the way to do it." Nothing wrong with this at all, but perhaps CI could look at maybe more explanation in the UserGuide regarding the deprecation.

I thought Javascript/Jquery is a big part of the present day internet. I have no problem with it not being in the CI framework, but as a noob, anything not explained well, or not explained at all, just sends up red flags. If only in this case, because I thought Jquery is so big.

Now I understand your pointer to caboose.

Your post raises another question: I decided to try CI because I was having difficulty with the highly rated Laravel. There, I found it is just getting into so much detail that it is really no longer a light-weight framework, but a good framework that comes with a steep learning curve.

At this stage of the game, CI fits my needs in being able to pass on what I learn to people beside me. If it gets too hard for me to understand what is going on, well, maybe our people will be spending half their time in school (good for BCIT) and the rest of their time actually doing something productive. 

A big item that brought me to both Laravel originally and now CI is built in (I think it is anyway)  csrf. I haven't found a snap-your-finger implementation so decided I would try frameworks which do this. So, sorry for the length of this post, but, you mention "authentication" as non-existent. Is this meaning I should be looking elsewhere for implementing csrf?

CSRF is built into Codeigniter. You need only change the setting in app/config/config.php to turn it on. Use the form helpers in your views and it will be included automatically.
Code:
$config['csrf_protection'] = TRUE;
Reply
#10

(11-05-2017, 10:50 PM)JeffreyB Wrote: No offense to Chicagophil and again, maybe I did not understand what he was saying, but I understood his comment to be, "go ahead and use it anyway, and this is the way to do it." Nothing wrong with this at all, but perhaps CI could look at maybe more explanation in the UserGuide regarding the deprecation.
Well the docs say, in a big bold block, right at the top,
Quote:This library is DEPRECATED and should not be used. It has always been with an ‘experimental’ status and is now no longer supported. Currently only kept for backwards compatibility.
Could not really be any clearer. Basic rule of thumb, if it is deprecated, do not use it.

(11-05-2017, 10:50 PM)JeffreyB Wrote: I thought Javascript/Jquery is a big part of the present day internet. I have no problem with it not being in the CI framework, but as a noob, anything not explained well, or not explained at all, just sends up red flags. If only in this case, because I thought Jquery is so big.
Jquery is big, some think too big. But there are hundreds, if not thousands of JS libraries. Some as big (IMHO) as jquery. Some do things jquery does not do or does not do well, others have entirely unique approaches to individual problems. Which you use is up to you. CI can work with all of them because they are all browser side technologies, and not server side. CI is server side.

(11-05-2017, 10:50 PM)JeffreyB Wrote: At this stage of the game, CI fits my needs in being able to pass on what I learn to people beside me. If it gets too hard for me to understand what is going on, well, maybe our people will be spending half their time in school (good for BCIT) and the rest of their time actually doing something productive. 
No, very unlikely (and a bit sarky 'good for BCIT'). If you have an app already written, others will find the CI learning curve to be very shallow, very PHP standard and not at all limiting. It neither tells you how to do something nor how you should do something. There is very little 'magic' and just a straight forward, powerful, mature and flexible framework of stable and well tested tools. None of which you actually have to use.

(11-05-2017, 10:50 PM)JeffreyB Wrote: A big item that brought me to both Laravel originally and now CI is built in (I think it is anyway)  csrf. I haven't found a snap-your-finger implementation so decided I would try frameworks which do this. So, sorry for the length of this post, but, you mention "authentication" as non-existent. Is this meaning I should be looking elsewhere for implementing csrf?
As answered before, CSRF is absolutely as simple as it could possibly be in CI. And yet you remain completely in control of it, when it applies, when it regenerates etc etc.

The key with CI, and possibly any other framework, is to spend some time playing and reading the docs. With CI this can take a few hours, or a day, or two days at most. After that you are away, doing whatever you need to do and being productive. Compared to other frameworks, it is superbly documented and is truly as easy to use as it is possible to be (again IMHO).

Wish you luck with your project and don't hesitate to post a new question if anything baffles. There are lots of people happy to help, explain or solve issues for you. Rest assured that it is almost certainly NOT a bug in CI that will have you scratching your head, but more the usual puzzles and headaches of website development which is completely normal in any coders programming life.

Best wishes,

Paul
Reply




Theme © iAndrew 2016 - Forum software by © MyBB