Zimbra offers Open Source email server software and shared calendar for Linux and the Mac
Go Back   Zimbra :: Forums > Zimbra Collaboration Suite > Zimlets

Welcome to the Zimbra :: Forums!
Welcome, if you would like to post a comment please register. We also encourage you to explore all things Zimbra with our team and members of the community.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-19-2009, 05:20 AM
Intermediate Member
 
Posts: 17
Default How to call a normal javascript in the zimlet?

I have a zimlet which talks to JSP and gets an XML response. I am giving an Ajax call to jsp page. SO in the callback function i get the "result.text" as XML. I parse it to form an html and display the data in the table form within zimlet dialog box. Following is the code snippet of the callback method.

com_mycomp_vm.prototype.onDoneRetrieve= function(result){

var txt = result.text;
my_html = this.par***ML(txt);

var view = new DwtComposite(this.getShell());
var el = view.getHtmlElement();

var div = document.createElement("div");

div.innerHTML=my_html; //CONTENT OF THE DIALOG BOX
alert(div.innerHTML);
el.appendChild(div);

//ARGS OF THE DIALOG BOX
var dialog_args = {
title : "Welcome",
view : view,
standardButtons : [DwtDialog.OK_BUTTON]
};

//CREATION OF THE DIALOG BOX
var dlg = this._createDialog(dialog_args);

//TEXT DISPLAYED ON THE OK BUTTON
dlg.getButton(DwtDialog.OK_BUTTON).setText("Close" );
dlg.popup();

}

In the parse method, I parse the data and form an HTML as follows:
com_mycomp_vm.prototype.par***ML = function(txt){

....
.....
html_table = "<table class='sortable' id='anyid' cellpadding='0' cellspacing='0'><tr><th>From</th><th>Subject</th><th>Size</th><th>Date</th><th>Attachment</th></tr>";
html_table = html_table + html_row + "</table>";


my_html = my_html + "<head> <meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1' /><title>Sortable table example</title>";
my_html = my_html + "<link rel='stylesheet' type='text/css' href='example.css'/><link href='http://www.joostdevalk.nl/' rev='made' />";
my_html = my_html + "<script type='text/javascript' src='sortable.js'></script></head>";
my_html = my_html + "<body>" + html_table + "</body>";

return(my_html);
}

In the table tag that I have created, I am trying to apply a class='sortable' to it. This is defined in a sortable.js file which is a simple javascript file(not zimletbase) which sorts the table as you click on the columns. If I apply this code to my simple html file it sorts the table. But then in this case it deos not. Could anybody tell me how can I do it?
Reply With Quote
  #2 (permalink)  
Old 01-19-2009, 06:43 AM
Zimlet Guru & Moderator
 
Posts: 288
Default

If you use firebug, does it give you any error?
Also, did you included the js file in com_mycomp_vm.xml like this :
Code:
	<include>sortable.js</include>
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads

Why Join?

Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.

blog.zimbra.com




 

SEO by vBSEO ©2011, Crawlability, Inc.