Javascript: coding the right way (mvc?) [closed] - javascript

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
Im starting to code with Javascript, but i have some conceptual questions about which is the right way to code using it. In this particular moment im working on a simple html file where my friends can fill data about their grades and percentages on a table, and i'll do some calculation with that and then display them.
My questions specifically are:
is it "better" to do calculation with data from the html table, or is
it better to have it stored in some array/matrix that changes when
html table is changed ( doing something like mvc style )?
if so, is it better to re-load info from view (table) every time i do
any calculation or there is anyway to make my inner variable to
change when view is changed?
I ask all this because i am so used to mcv style that working javascript and html in same file, and the ways javascript is presented on tutorials confuse me about how would it be if i want to have efficient, clean code
Thanks a lot, and please be comprehensive… this is my first question on SO !

If you are familiar with MVC and would like to code JavaScript using this framework I'd look into AngularJS .
As far as "better" ways to write code, I'd say for the size page you're talking about it doesn't matter all that much.
If you plan on editing the data and doing calculations from it, I would store the data using an array or matrix and then build a table from that data. With AngularJS any time you make calculations and change the variables effected by those calculations, you can reference those variables int he view and it will be updated automatically.

Related

How to create a blog with only index.html, style.css and script.js files? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
Inspiration for blog listing pages:
https://blog.hubspot.com/marketing
https://www.igomoon.com/blog
I only want to know from where should I start? from the beginning of the first line code? or Can import sample codes and edit them?
Should I develop index.html and style.css first? and after that script.js?
There are different approaches on how to realize such a project in general, strongly depending on what your skills are and how do you want to achieve your goals.
For example: If you already know how to write a page in simple HTML, do that first and build your skeleton in HTML. If you have placed all the things where you want to have them, you will find out that they are not looking very nice. If you know how to work with CSS you will add then your CSS. If you don't know how to work with CSS you need to learn that.
Once you have styled it with CSS you will figure out, that you page need to be filled with content and you will ask yourself how to do that. Then there are again several ways on how to do that. For example you maybe want to catch some data from Server X but don't know how to do that. You'll figure out, that you can fetch some data with node.js and then you need to learn node.js.
It's a ongoing process of figuring out:
1.) What you want to do
2.) Check out how to do that
3.) Learn the necessary skills
4.) Repeat points 1 to 3

How to created input data with Drupal? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
So, I've been doing programming and HTML for some time now. A lot of it is front end working with CMSs and stylizing. However there's one thing I've been wanting to learn.
When it comes to drupal, how do I go about creating something where a user can enter in text and it appears above? Honestly, I'm not sure if I'm even asking about it correctly. It's something a lot of websites already have so I'm sure it's not too difficult to answer.
The best example might be Basecamp. Essentially what I'm looking to do is that if a user is on a project they are apart of, I want them to write in a little text box (similar to what i'm doing right now) click submit and it appears in a comment section above. Some sort of simple form that links directly to a field I created in drupal.
Yes I do understand there's a comment module that's built into core but I'm looking to create something similar. Or even as similar as a twitter feed. A user just goes to his or her page and has a box for them to write out a small message.
Can someone point me in the right direction as it pertains to Drupal.
Best,
V
For data input, websites usually use forms. Drupal provies an Form API that you use to create forms and process their submission. You then need to process the submitted data and store them in the database. For that you will need Drupal's database abstraction layer. Finally, you will need to build page to display the form and the stored data. A page is the result of a controller method binded to a route. That result can either be a render array (see the Theme and rende for more information), or a Symfony Response object.

Getting updating in codebehind C# variable to asp.net [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I wrote a small code in c# that reads files from the hard drive and outputs that info to a webpage using asp.net.
Information about those files is being changed in the codebehind.
I managed to create variables to read and display the info on the webpage, but they change only after a refresh. When I used setTimeout it would always read the same variable, leaving me thinking that the codebehind does not get re-executed.
How would it be possible to have them updated live without needing to refresh the entire page?
This is somewhat vague but if you want updates to the values on your page after loading, you'll need to use some javascript to grab new values and then more javascript to update values on your page.
There are some great frameworks out there. Unless you have a lot of front-end logic you need to perform through javascript, I'd keep it as simple as possible and throw jQuery in there for the AJAX calls (fyi, this is not the only solution, there are 10+ different ways to skin this same cat).
If you want a bit more efficiency, you could look into using SignalR - which wraps long polling or web sockets (depending on browser capability) on the front end and signals those subscribing pages on the backend only when changes have occurred to data.
Link: http://www.asp.net/signalr
There is no "right" answer to your question so the best I or anybody can do is guide you in a direction. Hopefully this answer helps you.

Dynamic tables & boxes [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I'm creating a view wherein I need to add multiple boxes, wherein there is a number within the box, which is dynamically changing as per data (csv file)
Also, I'm adding tables, with dynamic numbers within the same which should again, change with the data (csv)
I'm trying to design an approach to get it done and looking for js libraries to use here.
Is there anything in particular that I should look for? Can tables be added without table command in html (alternatives)?
Any feedback would be highly appreciated.
This blog post is a simple representation of d3.js usage to load a csv to a html table.
Also there is already a StackOverflow post about loading csv data via php, if you are going for a backend approach.

Is creating html content using javascript is a good or bad [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I have seen in one of web application, they are creating entire dashboard HTML content using JavaScript methods, Why they are doing this ? by using JavaScript it will take much time to generate HTML tag and hard to debug and edit.
can someone explain what is advantage and disadvantage of using it ?
eg.
var ntfytab = new com.xyz.HTM('table',ntfy).init({width:'100%',id:"myTable02"});
var ntfyhad = new com.xyz.HTM('thead',ntfytab).init({});
new com.xyz.HTM('tr',ntfyhad).init({inner : new com.xyz.HTM('th',null)
.init({inner : 'Message'})});
If it is needed then it is ok, because almost all of the javascript libraries (jquery, prototype etc) plugins generate html in their code to be inserted in the page.
It is not a problem, it is just difficult and complex to understand :P
Disadvantage is the search engines dont read javascript.
There are lots of advantages. For example if you need to generate and display some html based on some conditions, some events etc then you can do it in javascript.
Think about image sliders, javascript based text editors and other animations effects based on javascript.
Creating tags by Javascript are not rendered by search engines... Or, they may have some sort of privacy control/check so that, no one(lay man) can copy their code..
It can be a suitable solution to output dynamic interfaces, eg tables where the number of rows etc may vary considerably (to output data received via ajax for example).
i would recommend only to create HTML by JS for dynamic content.
for static content alsways use your HTML files which are rendered before JS code will be executed!

Categories

Resources