Tag Archive: Javascript


Document ready in SharePoint

Last time, my team has worked with javascript on SharePoint page

There are a inject javascript on the page with a Script editor webpart. We did a try to run a function after page load with a common jquery fuction

$(document).ready()

As our expect, code included inside $( document ).ready() will run once the page Document Object Model (DOM) is ready for JavaScript code to execute. More detail about this function you can find more at http://learn.jquery.com/using-jquery-core/document-ready/

But our problem is the code was not execute as normal. So we work around on this

$(document).ready(function() {

setTimeout(function(){ execute code here},3000);

});

It works but it was not a good solution.

After research, I cannot remember exactly where, but finally I belive below code is the best solution for this issue.

SP.SOD.executeFunc(‘sp.js’, null, function(){
// Execute code here
})

 

Cheers

Hoang Nhut NGUYEN

JavaScript logo JavaScript has never been hotter, thanks to projects like Node.js, JQuery and PhoneGap. You can now use JavaScript for scripting in the browser, for creating desktop and mobile applications, and for creating server side web applications. But how do you get started? We’ve compiled a list of six free books and tutorials for beginning programmers, but those with programming experience may find some of these resources valuable as well. Feel free to add more free resources in the comments.

Experienced programmers may also want to take a look at this StackOverflow thread on the subject, but most of the resources there aren’t free.

Eloquent JavaScript

Eloquent JavaScript cover

Eloquent JavaScript is a JavaScript book by Marijn Haverbeke. The digital form is free, and a print version is forthcoming. The book assumes no prior programming experience. Of the books listed here, this one might have the most to offer experienced programmers looking to get started with JavaScript.

Sams Teach Yourself JavaScript in 24 Hours

Sams Teach Yourself JavaScript in 24 Hours cover

Sams Teach Yourself JavaScript in 24 Hours by Michael Moncur is part of the well known series of Sams books.

Learn to Program with Javascript

Learn to Program with Javascript is a series of tutorials from About.com. As the title implies, no programming experience is required.

W3Schools JavaScript Tutorial

W3Schools is one of the most venerable and respected resources for online tutorials, and of course it has its own JavaScript tutorial. It also has a stash of JavaScript examples, including some advanced scripts.

Wikibooks JavaScript

The Wikibooks book on JavaScript isn’t finished yet, but it’s one to watch. If you’re an experienced JavaScript programmer looking for a way to give back to the community, maybe you could contribute to this book.

SitePoint’s JavaScript Tutorials

Simply JavaScript

SitePoint is another well respected online source for tutorials and books. It has a few free tutorials, mostly as previews for its books. Its JavaScript Guru List is a good place to start.

Bonus: Douglas Crockford’s JavaScript Lectures

Well known JavaScript expert and JavaScript: The Good Parts author Douglas Crockford has a series of free lectures available on history of JavaScript, its features, and its use.

ReadWriteWeb

Hoang Nhut Nguyen
Email: nhutcmos@gmail.com
Skype: hoangnhut.nguyen
%d bloggers like this: