How do i utilize # to develop a one page application like gmail? - javascript

i want to develop a one page application where it should utilize AJAX to a full extent like the one used in Gmail and Facebook. i am aware of the light JS Framework called Sammy.js which does the work. the only thing why i don't want to use this is it is built on top of jQuery. i know jQuery is awesome and nice and i should start using it right away. but FYI i tend to learn things from scratch and later on i would want to adopt for Frameworks.
here is the link to what exactly i want to do..
http://nettuts.s3.amazonaws.com/763_sammyJSIntro/demo/index.html#/compose
is there any alternative so that i can achieve the same using plain Javascript?
thank you...

Since you'll be using jQuery, have a look at this plugin:
http://benalman.com/projects/jquery-bbq-plugin/
Edit: Oops, misread your question. I thought you do want jQuery.. but you don't.
Well.. still use it (or another javascript library if you don't like jQuery). First of all, you'll most likely not be aware of all browser-specific issues. Then your code will be much less readable if you use classic plain JavaScript for everything. If someone else will be working with your code he'll also have a hard time to get into it unless you document it really well.
So as you see, there's no good reason not to use jQuery in your app. If you want it for learning purposes ok - but then don't do that in a real application but with some small testcases.

using plain JavaScript to accomplish what you're looking to do is nice and educational and all, but using jQuery to accomplish it is soooo much quicker and effective. You could do XmlHttpRequests with callbacks etc., or you could $.ajax.
My advice, start learning jQuery now and start simple with a basic ajax request. You'll pick it up very quickly!

You can do it without JQuery, what you'll learn though is the million and one differences between each browser's javascript engine, and you'll have to account for all of them. Personally I think there's better things you could be learning, but up to you. If you want to, check out document.getElementById and go from there.

Related

Help me choose between Javascript, jQuery, or AJAX

before i start of with anything i know that jQuery and Ajax are the JS frameworks and it is nothing but JavaScript itself.
I started to learn Javascript few days ago, and then i realized the need to learn the AJAX and then suddenly i felt jQuery will be the better solution, heck i am confused here, i cannot go three at a time nor do i want to master all the three.
i am a web designer, i know, HTML, CSS, PHP and MySQL, i started to learn JavaScript on the purpose of learning the client side validations or some sort of animations for the website, i need the suggestion from the web gurus, i really don't want to get into the complex java script programming right now, all i want is the simple solution for performing various tasks like validation, and animation for my websites. is jQuery feasible solution for my problem? can i learn jQuery without much prior experience in Javascript. ?
JavaScript is a programming language.
Ajax is a thing you can do with that language.
jQuery is a library that does some heavy lifting in that language for you (including some things relating to Ajax)
You can't choose between them, it doesn't make sense.
is jQuery feasible solution for my problem?
Yes
can i learn jQuery without much prior experience in Javascript. ?
Yes, but you should get a decent understanding of JavaScript and DOM so you know what the library is trying to achieve. Otherwise you are poking around in the dark and won't produce as good results.
It is also very wise to understand progressive enhancement.
Normally I don't say this, but a better solution for you would be to look at jQuery. It is a framework written in JavaScript to make various tasks simpler and cross-browser. AJAX is nothing but just a function - XMLHttpRequest.
Since you don't want to delve deeper into the JavaScript language, the list of existing plugins available for jQuery will be helpful for you.
To understand where things stand in the spectrum
JavaScript is the language
AJAX or XMLHttpRequest is a function available in JavaScript.
jQuery is a framework written in JavaScript to simplify things
Firstly, JQuery is a AJAX library. AJAX is doing the communication manually on a lower level where as JQuery wraps in a higher level library.
Having done not much JQuery myself, I'm not entirely sure but I think you can achieve validation (and maybe animation) quicker by using inbuilt systems from JQuery, the alternative is to write it from scratch in javascript.
Although from the sounds of it if you want pure clientside animation or clientside validation there should be no need to use AJAX or JQuery. I'm not too certain about other libraries you could use for quick development.
My advice would be to learn javascript and keep an eye on whether any parts of JQuery can do exactly what you want it to do.
For example :
http://www.webreference.com/programming/javascript/jquery/form_validation/
Show's you how use JQuery to validate inputs in a rule based system (It looks almost like an extension of CSS)

Can I learn how to use jQuery with just a basic JavaScript experience?

The question is: Is it bad to learn how to do special effects, table sorting, etc, using jQuery instead of learning the bits of code that bring that alive with pure javascript?
I have previously addressed a similar problem in a question, but I missed adding this extra inquiry!
Yes you can. Doing it in JQuery isn't bad. Everyone uses some sort of Javascript library. I love JQuery. Your odds of making things that work in all browsers go up quite a bit, you get the UI done quicker, etc.
Though having a bit of Javascript knowledge is good, because when things go wrong you want to be able to debug the problem.
JQuery.com has lots of good tutorials.
You really should use jQuery; it will allow you to spend more time adding features instead of trying to make your code work in every browser (Note that even jQuery is not a silver bullet; you'll still have some cross-browser headaches in any non-trivial web app, especially if you need to support IE6).
There's no point in turning your back on new tools and libraries just to "stay close to the metal".
If you're afraid of lowering your value in your boss' eyes, look at it a different way. Would you prefer to hire a programmer who spends all of his time working around browser bugs, or a programmer who uses jQuery and finishes his projects faster because of it? Remember that managers are trying to ship products and make money, not simply hire elite programmers.
Personally I was recommended to learn JS before learning jQuery. But started off with jQuery, and can make pretty much with it without to much JS experience. What you do need to know of JS you can just google it and learn it when needed ;)
jQuery is fantastic for us that doesn't take the time to learn everything about JS
Personally, until the beginning of this year, I used to limit my use of javascript to only helping aid the user with things like web forms.
However, after playing around with jQuery for no more than a few days, I realised how much easier it made achieving javascript effects and functionality. Now I pretty much use jQuery on most web pages, a lot of the time, just to add nicer UI effects.
A background knowledge of raw javascript will never go amiss and you will almost certainly still have to mix it in with your jQuery scripts, but when you run into troubles, nearly every problem I've had, had a solution already posted on Stack Overflow or just on Google.
Not a very technical answer, but as an intermediate programmer, and javascript newbie I've had no problems learning to work with jQuery. The documentation and community are very helpful.
I think you should set yourself a goal of knowing javascript well enough to be able to author a plugin if you need it in your favorite framework. While using a framework is almost always the right way to go, there will be times when you can't find a plugin that does exactly what you need. At that point you need to know javascript well enough to be able to adapt a plugin to your needs or write your own.

Is it worth it to use jQuery for Ajax instead of building your own JavaScript?

Aside from the framework, is jQuery worth using rather than creating your own javascript? I've always debated if the framework was better to use than to create your own calls. Are their disadvantages of using it?
Sorry for beginner question, I'm trying to feel out if it would be better to use this and create some of the ajaxish workings of my site rather than develop it from scratch.
Are there other frameworks out there that would be better to use to create an ajaxish website?
Yes, jQuery is worth it. I speak as someone who resisted using any library for a long time, then finally saw the light.
I do recommend that you build some hand-rolled Ajax interactions before you dive into using jQuery for Ajax, so that you understand exactly what is happening with Ajax. Once that's achieved, though, let the library do the dirty work.
jQuery (and most other framework) are for making difficult things simple. It keeps you from having to write cross-browser compatabile code. It keeps you from having to write recursive methods to update multiple dom-elements. It basically cuts your development time down substantially, and saves you a lot of frustration.
Stackoverflow Archive:
Which Javascript framework (jQuery vs Dojo vs … )?
Great discussion (with lots of involvement) over various javascript frameworks. It will benefit you to browse this in depth, or even at a cursory level.
When should I use a javascript framework library?
Which Javascript Framework is the simplest and most powerful?
What JavaScript library would you choose for a new project and why?
Which Javascript Ajax Framework is most powerful and very lightweight?
Which javascript framework can be used for all browsers?
If you like reinventing the wheel, write your own. For me, I prefer to spend my time focusing on solutions rather than lines and lines of javascript code. I'll use JQuery to save resources and frustration
One thing I want to add is for the past couple of months, I was trying to fill a web developer position for my team, and it proved to be a difficult task.
Lots of folks knew how to use a JS framework (JQuery, ExtJS, YUI...), but once outside of the framework, they found themselves in an unfamiliar ground. I had a self-claimed senior JS developer with over 10 years of experience couldn't tell me how to use function.call() or function.apply() or how to implement simple inheritance in JavaScript.
Framework is great and definitely useful, but you will also want to make sure to know how to implement the basic OO concept and DOM manipulation without the framework.
BTW, we use ExtJS and if you are starting to pick a JS framework, you may want to look around to see which one suits you the most.
jQuery is a big project with many users. By that nature, it will be better tested than anything you write by yourself.
It is a great framework for most uses I've come to need.
Is there anything in particular you are trying to do?
jQuery helps you avoid worrying too much about cross-browser JavaScript issues, and helps you get things done quickly. As far as I'm concerned, the key reason for using it vs your own hand-rolled JavaScript probably is the "don't re-invent the wheel" cliché.
Apart from added productivity, JQuery's main plus is that it takes all (most) of the pain out of cross-browser testing.
There is no reason you cannot write your own code and splash in JQuery where needed. JQuery is incredibly lightweight for what it provides and you will quickly find that you can do most takes easier in JQuery (especially once you start using the plugins for it) than by hand. I am a big believer in not reinventing the wheel. The JQuery code is tested by tons of people and there are so many plugins to chose from I could almost guarantee that what I want to do has already been done before.
If you are starting with a clean site, now is the perfect time to take JQuery for a spin though, because if you do get hooked on it your code will be more consistent if you solve similar tasks using the same technique. Go give it a try :)
I would highly recommend using jQuery (or any comparable framework) over straight JavaScript. It just makes common programming tasks easier, most notably cross-browser development.
jquery makes js related work easier and more important standardised/compliant.
If you need re-assurance as to its use:
MS & Nokia are bundling it in their dev platforms.
Its compatible with many of the newest web technologies.
It has a large developer community supporting it.
There are many plug-ins available to aid RAD.
and more...
Give it a go!!
Definutly! Jquery wil save you a lot of time struggling over code and makes your code easier to read to non-experts.

Learning Javascript vs. jQuery

I got the Wrox.Beginning.JavaScript.3rd.Edition and wanted to start learning it from scratch, then my boss came along and said that why bother, learn jQuery.
Can I understand jQuery and work with it although I am a newbie and have limited knowledge in ASP.net, vb.net, some C#, and basic HTML?!
jQuery is javascript. I think you're on the right path. Learn javascript well and you'll be able to make better use of jQuery.
So what's your question? JQuery is a framework built on the top of a language JavaScript. To use JQuery confidently, you should get familiar with JavaScript. JQuery contains a bunch of useful patterns and utils that mask the incompatibilities of the browsers. Using a JavaScript framework make sense as it allows you to focus on your problem instead of the problem of the JavaScript implementations of the browsers.
For further details on JavaScript frameworks, see SO question »Which Javascript framework (jQuery vs Dojo vs … )?«. For learning JavaScript, learn the good parts.
if all your manager is asking from you is to show and hide some elements, or fade in and out a couple of images, or request some data via ajax and display it then learning jquery and its api is perhaps all that you need.
but if you (or your manager) are concerned about performance, maintainability, code reuse and generally understanding what the *ell is going on 'back there' then learning the language itself is a safe bet.
I would suggest grabbing a copy of JavaScript: The Definitive Guide, which will give you a general understanding of what it is and how to use it, and much more. While you are at it, I also suggest John Resig's Pro Javascript techniques. This guy really knows his javascript inside-out (works for mozilla, author of jQuery, amongst others).
As for jQuery, you don't really need to buy a book. Just browse through the API and have a look at its source code. Perhaps you won't understand much, but there are some cool stuff going on that will make you think.
It is entirely possible to learn jQuery without learning every bit of javascript first. However, to be productive and and extend the functionality of plugins etc you will need to know javascript.
I would suggest that you do a bit of both. Continue learning Javascript but when you want to implement functionality make use of the jQuery library.
I would say the statement is akin to you reading a C#/VB.Net book and having your boss say "Don't bother, just learn ASP.Net". You really don't get much from the latter without the former.
JQuery provides a good layer of abstraction for interacting with DOM elements. You can do a lot of interesting things with it quickly and easily. But there are probably many things that JQuery won't do for you. You'll need to use regular JavaScript for that.
jQuery removes the need for many bad Javascript habits.
However, you will frequently need to know more than just jQuery to get non-trivial work done.
You'll need to learn both, but try to pick up habits based on jQuery.
jQuery is made from javascript. :)
It would be a very good idea to read the source-code of jQuery to enhance your overall understanding of javascript...
Definitely learn both at the same time :)
Good luck and have fun.
Maybe your boss is trying to save you some time learning the basics of Javascript and start you off learning jQuery right away but I think this would be a bad idea.
Understanding the basics of javascript is key to using jQuery successfully. jQuery provides shortcuts and solutions to problems (cross browser problems etc) but it is not a language unto it's self.
My advice, learn javascript, learn about handling events in different browsers, inserting in to the DOM and then start using jQuery. You will appreciate it a lot more and be a better coder for it.
If you already have an understanding of C#, you'll have a head start learning Javascript and it shouldn't be too hard to pick up. I'd stick with that Javascript book though, since you need to know Javascript to use jQuery. Once you are comfortable with Javascript, move on to learning jQuery. The jQuery docs are VERY helpful and can answer almost any question you have.
Good luck with learning it, it'll be worth it.
jQuery Docs
what are U doing? - ofcourse pure JavaScript is better =)
Libraries will alwas contain nonessential complexity, but they can save some headaches if they're not too bloated or already present on the end users' systems. Best use would be to learn javascript while using jquery, and then slowly remove the crutch of using jquery. While it's powerful, it does add significant overhead, nonessential complexity, and potential opportunities for abuse, just like flash. There are no silver bullets.

How do I create a draggable and resizable JavaScript popup window?

I want to create a draggable and resizable window in JavaScript for cross browser use, but I want to try and avoid using a framework if I can.
Has anyone got a link or some code that I can use?
JQuery is more focused on a lot of nice utility functions, and makes DOM manipulation a whole lot easier. Basically, I consider it to be Javascript as it should have been. It's a supremely helpful addition to the Javascript language itself.
ExtJS is a suite of GUI components with specific APIs... Use it if you want to easily create components that look like that, otherwise, go with a more flexible framework.
JQuery would be a good way to go. And with the Jquery UI plugins (such as draggable), it's a breeze.. (there's a demo here).
Not using a framework, to keep it 'pure', seems just a waste of time to me. There's good stuff, that will save you tremendous amounts of time, time better spent in making your application even better.
But you can always check out the source to get some 'inspiration', and adapt it without the overhead of the stuff you won't use. It's well done and easy to read, and you often discover some cross-browser hacks you didn't even think about..
edit: oh, if you REALLY don't wan't no framework EVER, just check out their source then.. sure you can use some of it for your application.
Sometimes you can't choose your environment or architecture, so you're stuck working within constraints like not being able to use frameworks...
Avoiding a framework altogether will leave you with lots of code and a bunch of tedious browser-testing.
If you would consider a framework I'd suggest jQuery with the jqDnR plugin. I think it will solve your problem or perhaps you could combine the functionality of the jQuery draggables with the jQuery resizables
Just trying to avoid large framework downloads to the client for one very small thing, perhaps I am being daft.
I had looked at jQuery but also ExtJS, the documentation and UI 'look' seem far superior and professional in ExtJS ... are there particular reasons for you guys recommending jQuery?

Categories

Resources