Ok, let me see if I can break it down and help you.
Firstly, it is unclear how much you agree with your terminology, so I’m going to create a small glossary here, so I’m sure you understand what I mean:
- Request a life cycle . All HTTP request through your application. Ajax call is life cycles, page loading is life cycles, after sending a document and closing the connection, the life cycle ends.
- Controller Code responsible for monitoring the implementation of the request life cycle through your website.
- View Actual output code for any page / request. This is the code in
application/views and is used almost every time a request life cycle exists (with the possible exception of redirection and ajax). - Client Code Javascript logic occurs after the page loads. Ajax call is made using client code.
I'm going to answer your questions a little out of order, so bear with me:
This raises my first ridiculously simple question. This is normal? One of my main problems is, of course, users who do not have javascript; the application just does not work. I read about graceful deterioration and progressive improvement, but I'm just not sure if this application is without the possibility of using JS.
The fact is that Javascript is a pretty integral part of what we call "Web applications." The difference between a web application and a website is that it is intelligent. Most sites usually process requests and display relevant data, but applications usually make decisions, update the state of the system, and change the output based on input.
What you create, I would classify as a web application.
I do not believe in this day and the age of HTML5 (kinda) with facebook and youtubes today, which is unreasonable to require javascript to use the web application.
People who have disabled javascript these days do this through plugins like AdBlock and NoScript, which usually allow you to selectively disable things. The best way to deal with this is to separate your javascript from easily recognizable components so that users know which scripts to resolve.
Example
Site.js - Responsible for the function and operation of the site.Ads.js - Responsible for your ad
You cannot prevent users from blocking your ads; if you try, they usually just don’t use your service. (Assuming you're planning an ad)
So, create your graceful degradation to tell your users that your application needs JavaScript to work, you can even tell them which files are needed to facilitate the process.
The actual “planner” page is a completely different story. One of the first things that I was curious about was the ability to use / call functions from the view. If I follow the recommendations of MVC, I would say that I can not. So, now I collect all the data in the $ data arrays in my controller, and then exit them through jQuery AJAX calls directly to my web page.
Key to remember: MVC is not a rule. Although you are better off sticking to your system, you should apply it where necessary. You probably should not retrieve database records from your view, but when they are presented in some ready-made situations, this leaves you with two options:
- Break the paradigm a little where it makes sense (for good reason)
- Refactoring your system to implement a paradigm shift
Good example: Repeatable widget blocks, such as a tag block or a recent message block
The bottom line is that you probably don't want the data to be stored in $this->load->vars(...) or even worse in every $this->load->view in every controller function.
One approach is to redesign your system so that you have a common library of topics that collects general information and provides it, and then transfers your data of the form ( $this->load->view("someview", array(), true ) will display your view in a row instead of a page).
Another approach is to create a special view that has a simple task, using the model, loading the relevant data (cache, if possible) and displaying them. Like a widget, or an independent thing. This interrupts MVC but you need to study the reasons why we use MVC. The key is that the view should not be responsible for the implementation, so you can change the view, and the logic of the controller remains unchanged. Is this applicable? it may be a special component depending on the type, the controller may not know that it needs this information. Therefore, if you hold the pen on it and mark it so that you remember that it is responsible for yourself, you should be able to place it just fine.
Another thing I'm not sure about (AJAX-wise) is that I have two different AJAX calls to $ (document) .ready, and then like four more when the user clicks on different elements. I am also worried that jQuery.html () does not actually put content inside my html tags (when I look at the source).
It looks like you are trying to do too much in client code . Can any of these ajax calls to @start be represented by view ?
Four ajax calls when the user clicks on things? Most clicks are one action, usually one ajax, maybe two, is enough if you need to process the response and request additional information, but rarely more than that.
$.fn.html(...) jQuery places the first parameter inside the selected element. If you want to replace the HTML of the entire page (not recommended, ever ... it should be a page load). You would call it:
var theHtmlToPutInPage = "... whatever ..."; $("body").html(theHtmlToPutInPage);
My main problem when I got stuck now is the part for days. I have the headings for the grief on April 20, but then under them I need to get my actual events. I am not sure what would be the best approach to create this feature. Should I put it on the table? But then, how would I put certain events in the right place? At the moment, all that I have achieved is a function that outputs all the events for a given day into an array, for example:
There are many approaches to this problem. You could build the whole thing as a large table of temporary blocks, but this could become quite confusing. In addition, tables are bad. There are many well-written articles on when and where to use tables.
You can configure the visualization as a single grid using CSS Divs and swim the meeting add-in using position: absolute and be controlled using client code (javascript).
This is a rather difficult part of your project, there are many answers, and I don’t have time to really deeply dive into any decisions, you just need a prototype and experiment.
I want to provide a link to my source code (github) if someone wants to take a look at my mess and maybe try putting me on the right track again. Perhaps I AM on the right track, still; I just don’t feel it. I am stuck in the display-event part and I just feel terrible because I am not happy with what I wrote (although most of them work, for now).
I would be ready to consider it and give suggestions, as I am sure that some others will also be here.
As I am now at Easter breaks, I can’t contact my teacher for another week, so I am ready to provide 100-150 rewards for a review for a good, useful answer to this huge question / question.
As a rule, generosity should be used as a motivator in order to correctly answer your question. This is what makes people go deeper (for example, perhaps this answer, it becomes very long).
You can offer generosity, this is your representative, but don’t feel that you need to offer generosity. If this answer is satisfactory (or any other, someone else can post, just accepting the answer should be more than enough).
Summary and final thoughts
Well, that’s why in the process of writing this monster of the answer (is it still considered novels?) I think that I may have deduced where you make a mistake. It may be by design, but it may be random.
I think you may be mistaken in the presentation for the client code. When we talk about MVC, we do not mean that all of this should be loaded via ajax, and the view is javascript and dom running in the client browser.
If this is not the case, please ignore the last paragraph.
It looks like you have the wrong weight of duties. It looks like you are setting too much of your javascript application. Page loading is not the devil, ajax is trendy, but often it can be Too much . You must find the right one for your application. It looks like you could help simplify your problems by setting yourself a big responsibility for presenting instead of client code .
I hope this answer helped you, it is a pity that it took me so long to publish this, I saw your question when you posted it, but he did not have time to delve into it.