\n';
38 | if(settings.target.length > 0){
39 | $(settings.target).html(output);
40 | }else{
41 | $(table_target).before(output);
42 | }
43 | });
44 | };
45 | })(jQuery);
46 |
--------------------------------------------------------------------------------
/README.rdoc:
--------------------------------------------------------------------------------
1 | == Jquery plugin to convert tabular data into divs
2 |
3 | This plugin was developed to convert tabular output into divs for more control of style and layout. In a popular CMS we use it's easy to write custom SQL to pull data out of the database and render it in a table. It's a lot more work to try and query that data and then output that data in a more usable format that can be styled.
4 |
5 | This is a quick little way to just convert the table.
6 |
7 | === JavaScript Usage
8 | Select the table you want to convert
9 |
10 | .table_to_div() takes two optional arguments.
11 |
12 | prefix: which will prefix your divs with something you select, or if you leave it empty it will prefix everything with tg
13 |
14 | target: if you specify a target it will add the div conversion into that target element. This would most likely be an id or class for another div on the page.
15 |
16 | If left empty the divs will be added before your table.
17 |
18 |
25 |
26 |
27 | === Example Target HTML
28 |
29 | Example here has mixed th / td in the header row to support both syntax.
30 | Currently designed where the leading row is always a header row.
31 |
32 |
33 |
34 |
35 |
36 |
First Name
37 |
Last Name
38 |
Company
39 |
Image Path
40 |
Address
41 |
Address 2
42 |
City
43 |
State
44 |
Zip
45 |
46 |
47 |
Ryan
48 |
Doom
49 |
Web Ascender
50 |
/whatever/something.jpg
51 |
4151 Okemos Rd
52 |
STE B
53 |
Okemos
54 |
Michigan
55 |
48864
56 |
57 |
58 |
John
59 |
Doe
60 |
Web Ascender
61 |
/images/whatever.jpg
62 |
4151 Okemes Road.
63 |
STE B.
64 |
Okemos
65 |
MI
66 |
48864
67 |
68 |
69 |
70 | === Example Output
71 |
72 | Conversion of the above table. Right now it removes the spaces out of the heading rows, but a future change may be to remove any invalid characters for a class element.
73 |
74 |
75 |
76 |
77 |
78 | Ryan
79 |
80 |
81 |
82 | Doom
83 |
84 |
85 |
86 | Web Ascender
87 |
88 |
89 |
90 | /whatever/something.jpg
91 |
92 |
93 |
94 | 4151 Okemos Rd
95 |
96 |
97 |
98 | STE B
99 |
100 |
101 |
102 | Okemos
103 |
104 |
105 |
106 | Michigan
107 |
108 |
109 |
110 | 48864
111 |
112 |
113 |
114 |
115 |
116 | John
117 |
118 |
119 |
120 | Doe
121 |
122 |
123 |
124 | Web Ascender
125 |
126 |
127 |
128 | /images/whatever.jpg
129 |
130 |
131 |
132 | 4151 Okemes Road.
133 |
134 |
135 |
136 | STE B.
137 |
138 |
139 |
140 | Okemos
141 |
142 |
143 |
144 | MI
145 |
146 |
147 |
148 | 48864
149 |
150 |
151 |
152 |
153 | === Common Usage
154 |
155 | * Convert tabular data into div tags
156 | * Transform a table into div
157 | * Javascript to convert a table to div tags
158 | * jQuery to convert table to div or span tags
--------------------------------------------------------------------------------