File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Create a Table as a jQuery plugin Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Create a Table as a jQuery plugin" Watch "Create a Table as a jQuery plugin" New topic
Author

Create a Table as a jQuery plugin

samuel marin
Greenhorn

Joined: Nov 18, 2011
Posts: 16
I would like to know how can I create a HTML table in JQueryP code dinamicaly.

I would like to create a simple table like:

<table bgcolor=white width="245">
<tr>
<td>
<font color=darkblue size=3>Category 1</font>
<br>
<font color=#1dc4ff size=2><a href="">Element 1</a></font>
<br>
<font color=#1dc4ff size=2><a href="">Element 2</a></font>
</td>
</tr>
</table>



In something that I can code in my .jsp file. Something like:


(function( $ ) {


$.fn.MyTable = function(options) {

});
};


Thank you so much
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61415
    
  67

JSP or jQuery? You ask about JSP and then show code that creates a jQuery plugin.

Also, attributes such as bgcolor and tags such as <font> are deprecated and should not be used.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
samuel marin
Greenhorn

Joined: Nov 18, 2011
Posts: 16
Sorry, I was refering to JQuery.

Thanks

I'm trying to be able to create a Table dynamically since I'm going to have it in many different sites I don't want to change the table in all the sites each time I need to modify the table.

I tried the following and I don't know why is not working:


Calling it:

Thanks again
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61415
    
  67

Please read ItDoesntWorkIsUseless and tell us in detail what's not working.

Also, have you launched the JavaScript debugger and tried stepping through the code to see where it's going awry?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61415
    
  67

What is the purpose of calling the plugin on "#sidebar-lef" if you've hard-coded the table parent as "#output"?

Also, the table element is not self-closing, specify one of $('<table>') or $('<table></table>').
samuel marin
Greenhorn

Joined: Nov 18, 2011
Posts: 16
Here is the jsfiddle of what I'm trying


http://jsfiddle.net/samuvk/fbvXn/

Thanks
samuel marin
Greenhorn

Joined: Nov 18, 2011
Posts: 16
Solved.

Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Create a Table as a jQuery plugin