-
8 Dec 2009 6:52 PM #1
Unanswered: simple fn of jquery equiv.
Unanswered: simple fn of jquery equiv.
I want to use Ext Core API to write a test fn named table.
// jquery version for referenceCode:... "table": function(){ // in a 40-iteration for loop: // create a table with the class "madetable", and append it to the DOM // add a row with one cell to the table. the cell content should be "first" // add a new cell before the first cell in the row. // // return the length of the query "tr td" }, ...
I found it's not easy for me to write a ext core version of jquery equiv.Code:... "table": function(){ for(var i = 0; i < 40; i++){ $("<table class='madetable'></table>") .appendTo("body") .html("<tr><td>first</td></tr>") .find("tr").prepend("<td>before</td>"); } return $("tr td").length; }, ...
some requirements:
write a simple and concise fn, shortest is best
only write codes within function body
Ext Core API only, don't use any Ext.apply/applyIf/override/extend
-
9 Dec 2009 1:29 AM #2Sencha - Ext JS Dev Team
- Join Date
- Mar 2007
- Location
- Notts/Redwood City
- Posts
- 30,458
- Vote Rating
- 20
- Answers
- 9
You seriously just want to create 40 consecutive tables in your application?
Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
9 Dec 2009 1:42 AM #3Sencha - Ext JS Dev Team
- Join Date
- Mar 2007
- Location
- Notts/Redwood City
- Posts
- 30,458
- Vote Rating
- 20
- Answers
- 9
But if you insist:
Code:function() { for (var i = 0; i < 40; i++) { Ext.getBody().createChild("<table><tbody><tr><td>first</td></tr></tbody></table>") .child("tr") .insertHtml('afterBegin', '<td>before</td>'); } return Ext.query("tr td").length; }Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
9 Dec 2009 8:22 AM #4
Actually just for test of Taskspeed

Thanks for your quick reply.
seems you merged step1(append table dom node) and step2(insert a row with one cell),
so I have to write like this:
Code:function() { for (var i = 0; i < 40; i++) { Ext.getBody().createChild('<table class="madetable"></table>') .createChild('<tr><td>first</td></tr>') .child('tr') .insertHtml('afterBegin', '<td>before</td>'); } return Ext.query("tr td").length; }


Reply With Quote