Spry.Utils.addClassName(element,classname);
addClassName will add a CSS class to the specified element. A class attribute does not have to be on the element. If the element has an existing class applied, this function will add it to the element, not replace it.
element
classname
<style type="text/css">
<!--
.dada {
background-color: #FFCC33;
}
-->
</style> <script> function setClass(ele,class){
Spry.Utils.addClassName(ele,class);
} </script> <a href="#" onclick="setClass('content','dada');">Add Class</a> <div id="content">Change This Text</div>
Spry.Utils.addEventListener = function(element, eventType, handler, capture)
addEventListener registers a non-destructive event handler on the specified element. See also removeEventListener.
element
eventType
handler
capture
Spry.Utils.addEventListener = function(handler)
addLoadListener add non-destructive event listener to the onLoad event.
Handler
Spry.Utils.addLoadListener(function() { setTimeout(function() { Spry.Data.initRegions(); }, 0); });
Spry.Utils.eval(string);
Call this method from your JS function when you don't want the JS expression to access or interfere with any local variables in your JS function. A standard js eval.
String
Spry.Utils.getNodeText(elementID);
Returns the text of the specified Element
elementiD
<script>
function getText(node){
var x = Spry.Utils.getNodeText(node)
alert(x);
}
</script>
<p><a href="#" onclick="getText('removeMe');">Get Inner Text</a></p>
<div id="removeMe">This is the Inner Text</div>
Spry.Utils.loadURL = function(method, url, async, callback, opts)
loadURL gets the actual XMLHTTPRequest to the server and handles the returned value.
Spry.Utils.loadURL = function(method, url, async, callback, opts)
method
url
async
N/A
var observer = { onPostUpdate: function(notifier, data) { var acc = new Spry.Widget.Accordion("Acc1"); } };
Spry.Data.Region.addObserver("Acc1", observer);
Spry.Utils.removeAllChildren(elementID);
removeAllChildren will remove all the child content of the specified element, but leave the container of the specified ID.
elementiD
<script>
function removeTheChild(node){
Spry.Utils.removeAllChildren(node)
}
</script> <a href="#" onclick="removeTheChild('removeMe');">Remove Inner Text</a> <div class="codeSample" id="removeMe">Inner Text</div>
Spry.Utils.removeClassName(element,classname);
removeClassName will remove a CSS class to the specified element. A class attribute does not have to be defined on the element, it can remove a class that has been set with addClassName(). If the element has an existing class applied, this function will remove the class name to the element.
element
classname
<style type="text/css">
<!--
.dada {
background-color: #FFCC33;
}
-->
</style> <script> function removeClass(ele,class){
Spry.Utils.removeClassName(ele,class);
} </script> <a href="#" onclick="removeClass('content','dada');">Remove Class</a> <div id="content" class="dada">Change This Text</div>
Spry.Utils.removeEventListener = function(element, eventType, handler, capture)
removeEventListener removes the non-destructive event listener specified. See addEventListener
element
eventType
handler
Spry.Utils.stringToXMLDoc(xmlStr);
stringToXMLDoc converts a string that is XML into an actual XML DOM object. This object can now be used as a source for a data set.
xmlStr
var xmlStr = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?> \
<employees xmlns=\"http://www.foo.com/employees\"> \
<employee id=\"123456\"> \
<lastname>Smith</lastname> \
<firstname>Edward</firstname> \
<phone>(415) 333-0235 </phone> \
<username>esmith</username> \
</employee> \
<employee id=\"127937\"> \
<lastname>Johnson</lastname> \
<firstname>Neil</firstname> \
<phone>(415) 333-9475 </phone> \
<username>njohnson</username> \
</employee> \ </employees>";
var dsEmployees = new Spry.Data.XMLDataSet(null, "/employees/employee");
var xmlDOMDocument = Spry.Utils.stringToXMLDoc(xmlStr);
dsEmployees.setDataFromDoc(xmlDOMDocument);