CHUVASH.eu
  • About
  • Search

Posts

March 3, 2012

Hello world in node.js

I know, node.js has been present for a while. But I actually had no time to try it. I was surprised that now it is very straight forward to start with node.js. Allright, everything begins with Hello world. Eventhough it is available for allmost all combinations of operating systems and servers, the easiest way to test it was actually Ubuntu. To install just run:

sudo apt-get install nodejs
```Then make a new directory and create the hello.js:

mkdir hello cd hello vi hello.js

read more
March 2, 2012

New functions in jQuery 1.7+ on and off

A simpler interface for event handling in jQuery. Just read Dan Wahlin’s blog.

read more
February 28, 2012

cross browser console.log

console.log is the best tool for debugging javascript. In Firefox Firebug and Chrome Dev Tools you can even log objects which are represented as tree nodes of properties. If Firebug or Dev Tools in Chrome and IE9 are not opened, all these messages are ignored. But IE8 doesn’t understand console (if Dev Tools are closed) and raises an error: To avoid these errors, just declare an empty function just for IE8–:

read more
February 28, 2012

javascript: passing arguments from popup to main window

To show a popup, we just have to invoke “window.open”, and provide some options to prevent opening this in a new tab:

var wnd = window.open('', '\_blank', 'width=750, height=400, location=no, resizable=1, menubar=0, scrollbars=0');
wnd.document.write('');
wnd.document.close(); wnd.document.close(); wnd.focus();

To communicate between parent and child we can refer to parent as window.opener. We can even invoke a function from parent window. Let’s create the most useful function:

read more
February 26, 2012

javascript: serialize as xml

Why should we need to serialize javascript objects as XML. I don’t know. It is of course more a server side need. And there actually a need for javascript serialization as xml in node.js. To serialize as json is very simple: JSON.stringify(myobjects). I was just curious if there was a tool for xml serialization in javascript. There is a nice javascript tool called XMLWriter, developed by Ariel Flesler. Consider you have articles and want to serialize them as xml, let’s create a function for serializing:

read more
February 22, 2012

Enable Save in IE9 mode

Wouldn’t it be nice to use html5 and css3 in SharePoint? No problems, there is actually v5 master out there, created by Kyle Schaefer. Or just use h5ml5 and css3 right away in your webparts and pages. But there is a big problem. It doesn’t work in IE9–. One of the issues (even listed by Kyle) is that “save” doesn’t work in modal dialogs where Rich Text Editor is used. Especialy it is for modal dialogs. The problem is not IE9, neither html5 and css3. After some digging in javascript code which is shipped with SharePoint I found out that the problem is some legacy javascript code which is not supported by IE9 but in IE8– (and compatibility mode). When we set IE9 mode in IE9 Dev Tools (F12) and go to Tasks list and try to create a task, we’ll get an error: It is RTE_GetEditorIFrame from init.js:

read more
February 21, 2012

$().SPServices is best for SOAP

SPServices is a great tool, really nice work, Marc Anderson (@sympmarc). It has been there all the time I have developed for SharePoint. But the fact that you work with XML and you must parse the attributes (!) was the reason why I prefered listdata.svc and Client Object Model, where you get objects in JSON or you have a nice API to get objects and their properties. But there is an area where SPServices are really the best tool: SharePoint Web Services which only understand SOAP like SocialDataService.asmx.

read more
February 14, 2012

$ and jQuery in SharePoint

Do you still use $ for jQuery? Well, don’t. If your code with $ resides with a SharePoint Images webpart, it will stop working. You’ll get errors like

Uncaught TypeError: Cannot call method 'empty' of null

The reason is that SharePoint uses $ in its own javascript code: CMSSiteManager.js

function $()
{ULSjlC:;
   var elements=new Array();
   for (var i=0; i < arguments.length; i++)
   {
	  var element=arguments\[i\];
	  if (typeof element=='string')
	  element=document.getElementById(element);
	  if (arguments.length==1) return element;
	  elements.push(element);
   }
   return elements;
}
read more
February 14, 2012

onchange isn't firing in IE

I don’t know why, but (not always, just sometimes) IE doesn’t fire the onchange event (which is added as an attribute on an html element). A better “workaround” is to add an eventlistener in javascript. Or a lazy workaround is to use the onclick event even for checkboxes.

read more
February 13, 2012

ScriptResx.ashx in SharePoint

In my previous post I showed a little proof-of-concept for an httphandler which I want to use to dynamically get the localization resources from SharePoint as javascript object. But wait a moment. How does SharePoint handle localization on client? When you look in Script tab in Chrome dev tools, you’ll find:

ScriptResource.axd

It is added to the server when deployed. See a good introduction to WebResource.axd and ScriptResource.axd by Brian Chavez.

read more
  • ««
  • «
  • 23
  • 24
  • 25
  • 26
  • 27
  • »
  • »»
© CHUVASH.eu 2025