0

I re-render jqmobile table this way and all work:

var List = React.createClass({

  componentDidMount:function(){
    $(".list-box-app-list").table();
  },

  componentDidUpdate:function(){
    $(".list-box-app-list").table();
  },

  render: function() {
    var allListItems = this.props.allListItems;
    var listItems = [];

    for (var key in allListItems) {
      listItems.push(<ListItem key={key} list_item={allListItems[key]} />); 
    }

    return (
      <table  data-role="table" data-mode="columntoggle" className="ui-responsive list-box-app-list">
        <thead>
          <tr>
            <th data-priority="2">Id</th>
            <th>Author</th>
            <th data-priority="1">Text</th>
          </tr>
        </thead>
        <tbody>
          {listItems}
        </tbody>
      </table>
    );
  }

});

Example is here: https://eugen35@bitbucket.org/eugen35/flux-todomvc.git

branch: listAndJQMobile

npm install
npm run watch // create bundle.js
npm start // run server.js

Is there way to do this more optimally?

Cause my example i think work so: 1) (re)render JSX in DOM, 2) INITIALIZE JQMobile-table with .table(); Earler I have supposed, that reactDOM only renew some new rows in my table and i do not have to reinitialize JQM-table. But this not work. Probably reactjs after each update rerender in DOM whole table. And from that i need to reinitialize it as JQM table.

What do i do wrong?

meugen
  • 1
  • 1
  • I have noticed, that JQM tables works incorrect in my case: – meugen Mar 20 '16 at 22:09
  • After i have dynamicaly added some row, - for those rows component does not work, - they were not be hidden, when i change window size. To all work i have changed code above for this: – meugen Mar 20 '16 at 22:15
  • ' componentDidMount:function(){ $(".list-box-app-list").table().table("refresh"); }, componentDidUpdate:function(){ $(".list-box-app-list").table().table("refresh"); },' – meugen Mar 20 '16 at 22:16
  • **But question about optimality of my code is still on the agenda!** – meugen Mar 20 '16 at 22:17

0 Answers0