Results 1 to 4 of 4

Thread: simple fn of jquery equiv.

  1. #1
    Sencha User
    Join Date
    Dec 2007
    Posts
    167
    Vote Rating
    0
      0  

    Default Unanswered: simple fn of jquery equiv.

    I want to use Ext Core API to write a test fn named table.
    Code:
             ...
    	"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"
    	},
             ...
    // jquery version for reference
    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;
    	},
             ...
    I found it's not easy for me to write a ext core version of jquery equiv.

    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

  2. #2
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,607
    Answers
    15
    Vote Rating
    58
      0  

    Default

    You seriously just want to create 40 consecutive tables in your application?

  3. #3
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,607
    Answers
    15
    Vote Rating
    58
      0  

    Default

    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;
    }

  4. #4
    Sencha User
    Join Date
    Dec 2007
    Posts
    167
    Vote Rating
    0
      0  

    Default

    Quote Originally Posted by Animal View Post
    You seriously just want to create 40 consecutive tables in your application?
    Actually just for test of Taskspeed

    Quote Originally Posted by Animal View Post
    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;
    }
    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;
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •