Skip to content

Sortable tables in markdown using javascript #6293

Discussion options

You must be logged in to vote

I solved it by using another library and another method to append a class in the table tag. Under Admin / Theme I injected this into the HTML head:

<script type="text/javascript">
  function addSortable() {
    var tags = document.getElementsByTagName("table");
    for (i = 0; i < tags.length; i++) {
		tags[i].className = "sortable";
	}
  }
  window.onload = function() {
    addSortable();
  };
</script>

And in the HTML body I injected sortable.js

Finally, this CSS injection adds some arrows next to the column titles, although I feel this needs some fine tuning:

table.sortable thead {
  background-color: #eee;
  color: #123;
  font-weight: 700;
  cursor: default
}
table.sortable th:not(.s…

Replies: 3 comments 5 replies

Comment options

You must be logged in to vote
4 replies
@mb0x88
Comment options

@mittkkoo
Comment options

@mittkkoo
Comment options

@mittkkoo
Comment options

Answer selected by mittkkoo
Comment options

You must be logged in to vote
1 reply
@mittkkoo
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants