@Bogdacutu Welcome to the JavaScript chat! Please review the room pseudo-rules. Please don't ask if you can ask or if anyone's around; just ask your question, and if anyone's free and interested they'll help.
@Markus403 Welcome to the JavaScript chat! Please review the room pseudo-rules. Please don't ask if you can ask or if anyone's around; just ask your question, and if anyone's free and interested they'll help.
@ThiefMaster Markup that is generated from the server and enhanced with JavaScript is a bad approach to begin with. If you're doing the mark up in JavaScript, pass a JSON object, and do the markup with a templating engine on the client side.
@BenjaminGruenbaum: not really a good solution if stuff should be properly indexable by search engines and maybe even be partially usable for users who disabled js
@ThiefMaster I'd even go as far as extracting the data from the markup, building a JSON object, and having a proper model to work with rather than 'attaching' markup.
To test if a point is within a circle, you want to determine if the distance between the given point and the center of the circle is smaller than the radius of the circle.
Instead of using the point-distance formula, which involves the use of a (slow) square root, you can compare the non-square-...
@SimonSarris we had this discussion with @Loktar a while ago, turns out not using Sqrt is surprisingly not much faster. I was arguing your stand by the way
@ThiefMaster There are solutions to SEO in SPAs, we're not the first two people discussing how to make an AJAX site SEO friendly, Angular has a whole section on it. The easiest thing to do is crawl your own site with a smarter UA, and make SEO friendly pages
@BenjaminGruenbaum But you usually do not have an object's ID in the normal markup at all. After all, it's usually nothing you show to users. And having it in an hidden element would be really ugly.
@ThiefMaster The DOM should not be aware of it to begin with! Your source of information should be a JavaScript object, and not the DOM. That's separation of concerns 101. If I want to ask my collection something, I do not intend to ask an HTML structure representing the collection anything. What I intend to do is ask my collection, which JS represents as an array something.
@FlorianMargaine oh dude thanks a lot, sincerilly i have an array of english => french things, if i prepare you can you check that please? it's not so long :P really
@ThiefMaster For anything, when you're storing data-attributes you're not writing code like an application, you're making a "document dynamic", you're writing PHP4.
@BenjaminGruenbaum when you're making a throwaway project, it doesn't really matter if it's a tiny web-app (model/view) or just a dynamic web page (model=view)
@FlorianMargaine np man i just let you check that when finished i put only relevant things i'm unable to translate correctly, then as you want if you boried np i'll try going on by myself :P thanks
@JanDvorak So your argument is that it's ok to write bad code when you're making a project that you think is a throwaway because code structure and maintainability is not important in such cases?
@JanDvorak The only thing I'm claiming is that a good design must obey separation of concerns. I don't understand what you're saying 'Well, sometimes a bad design is a good idea"
@JanDvorak I didn't say Knockout either in this debate, not once. Around 3000 lines before minification.
@JanDvorak A design that mixes what we're viewing and what objects we're working with is a bad design. data-* attributes are the pinnacle of that bad practice. Even if I were not using jQuery or Knockout at all, I can simply have the object in the closure scope when I attach the event listener, tada, data-binding.
@JanDvorak I'm not suggesting MVC, or any other specific design pattern, all I am saying is that a fair design must separate what I'm showing and my business logic. data- attributes rape that concept to hell.
@JanDvorak Again no, you can bind the entire data and events to the elements when creating the relevant elements in closure scope, this is part of why closures are so powerful, the event listeners are implicitly bound to the model in the closure.
@BenjaminGruenbaum - Hey, were you able to get that PDF on nested stack automata? I read every other article on the web but I still can't wrap my head around it.
@JanDvorak You're saying "well, it doesn't matter for a small project", I agree. Writing bad code for small projects who die soon is not nearly as bad as writing bad code for big projects, if you're willing to take the risk your project will die soon, and you're ok with producing bad code, which I'm not.
@JanDvorak Now you stopped making sense, what does 'caching' the code mean? (that's not an insult, I'm just not understanding what you're saying) It can still be a .js file if that's what you're referring to.
@AaditMShah Sorry, I completely forgot about it -_-'
@BenjaminGruenbaum - A lot of JS programmers use the constructor pattern of prototypal inheritance. Not the prototypal pattern of prototypal inheritance.
@JanDvorak you mean that a JSON response can't be cached? What do you mean cached? I have event listeners that are bound to the closure of the data in the IIFE, I have access to the data in my business logic, what are you talking about when you're saying 'caching'?
@JanDvorak deep down in your heart you know you're just arguing now for the sake of arguing. You're a good coder, and you know the value of separation of concerns, you feel the problem with data attributes and storing the actual model in the DOM. Step down from that tree. data- attributes are a bad idea formed by the jQuery crowd who do not understand separation of concerns. We both know this.
@BenjaminGruenbaum either the code must be inside the IIFE (hence, uncacheable) or outside the IIFE (hence, you must store something in the global namespace)
There is no problem in saying your HTML is your view and should be aware of state and update accordingly, the issue is with the DOM storing application state
@badbetonbreakbutbedbackbone best bet to get this done for free would be to use google translate first, then take your lists to a forum that deals with said language and ask them to review to ensure it all makes sense
@JanDvorak Here, trivial one. My entire application code is stored in a single global which has a .injectData method, my data is a separate JS file which starts with .injectData({/*data here */) , I can even remove it from the global namespace (my app name) later if you'd like
asking here probably won't do you any good. it is a better request for a long term post on a forum. that way it will be viewed by many people over time and in a week you might get everything you need for free.
@JanDvorak There is nothing in the global namespace -_- are you even reading my messages? Also, we're not even talking about the problem with globals, that's not the topic of discussion at all. We're talking about separation of concerns, storing data in the presentation - that's the problem. Treating what you're showing to the user as a source of truth - same problem.
what am i doing wrong when i have this array ["110117223699", "110117223704", "110117224033"] and i delete one so i have this ["110117223704", "110117224033"] but arr.length still = 3 ?
@JanDvorak In an IIFE, just like other modules in loaders like Require work for example. How is where the code is even remotely related to the problem of having model data in the view? THAT is the problem.
@FlorianMargaine - Not to sound stupid, but what's the point of these utility belts. I know they provide a set of functions you find in languages like Haskell. However for me 1) Function call overhead in JavaScript is too much 2) Most of these utility belts aren't structured well - it's just a bunch of functions in a namespace. So I would rather write the function myself and then continue working.
@BenjaminGruenbaum I'm afraid I don't understand. Can you show me an entire (self-contained) code sample including the separation to files and the cache settings?
@JanDvorak Require exposes two globals iirc "require" (start here) and "define" define a module. It works quite nicely. Still, I think deep in your heart you see the problem with data- attributes
@JanDvorak Yeah, pretty much, you should check it out it's fun to know
@badbetonbreakbutbedbackbone First of all, the main difference is that Bootstrap is not purely CSS like this framework and second, Bootstrap is just a framework that happens to also be responsive.