Sortable - 图1

Sortable Vue Component

Sortable is not a separate component, but just a particular case of using and components.

Sortable Events

EventDescription
<f7-list> events
The following events will be available on <f7-list> when sortable prop enabled
sortable:enableEvent will be triggered when sortable mode is enabled
sortable:disableEvent will be triggered when sortable mode is disabled
sortable:sortEvent will be triggered after user release currently sorting element in new position. First handler argument contains object with from, to and el properties with start/new index numbers of sorted list item and the HTML element of sorted list item

Examples

  1. <template>
  2. <f7-page>
  3. <f7-navbar title="Sortable List">
  4. <f7-nav-right>
  5. <f7-link sortable-toggle=".sortable">Toggle</f7-link>
  6. </f7-nav-right>
  7. </f7-navbar>
  8. <f7-block>
  9. <p>Just click "Toggle" button on navigation bar to enable/disable sorting</p>
  10. </f7-block>
  11. <f7-list sortable @sortable:sort="onSort">
  12. <f7-list-item
  13. title="1 Jenna Smith"
  14. after="CEO">
  15. <f7-icon icon="icon-f7" slot="media"></f7-icon>
  16. </f7-list-item>
  17. <f7-list-item
  18. title="2 John Doe"
  19. after="Director">
  20. <f7-icon icon="icon-f7" slot="media"></f7-icon>
  21. </f7-list-item>
  22. <f7-list-item
  23. title="3 John Doe"
  24. after="Developer">
  25. <f7-icon icon="icon-f7" slot="media"></f7-icon>
  26. </f7-list-item>
  27. <f7-list-item
  28. title="4 Aaron Darling"
  29. after="Manager">
  30. <f7-icon icon="icon-f7" slot="media"></f7-icon>
  31. </f7-list-item>
  32. <f7-list-item
  33. title="5 Calvin Johnson"
  34. after="Accounter">
  35. <f7-icon icon="icon-f7" slot="media"></f7-icon>
  36. </f7-list-item>
  37. <f7-list-item
  38. title="6 John Smith"
  39. after="SEO">
  40. <f7-icon icon="icon-f7" slot="media"></f7-icon>
  41. </f7-list-item>
  42. <f7-list-item
  43. title="7 Chloe"
  44. after="Manager">
  45. <f7-icon icon="icon-f7" slot="media"></f7-icon>
  46. </f7-list-item>
  47. </f7-list>
  48. <f7-list media-list sortable @sortable:sort="onSort">
  49. <f7-list-item
  50. title="Yellow Submarine"
  51. after="$15"
  52. subtitle="Beatles"
  53. text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sagittis tellus ut turpis condimentum, ut dignissim lacus tincidunt. Cras dolor metus, ultrices condimentum sodales sit amet, pharetra sodales eros. Phasellus vel felis tellus. Mauris rutrum ligula nec dapibus feugiat. In vel dui laoreet, commodo augue id, pulvinar lacus."
  54. >
  55. <img slot="media" src="https://cdn.framework7.io/placeholder/people-160x160-1.jpg" width="80" />
  56. </f7-list-item>
  57. <f7-list-item
  58. title="Don't Stop Me Now"
  59. after="$22"
  60. subtitle="Queen"
  61. text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sagittis tellus ut turpis condimentum, ut dignissim lacus tincidunt. Cras dolor metus, ultrices condimentum sodales sit amet, pharetra sodales eros. Phasellus vel felis tellus. Mauris rutrum ligula nec dapibus feugiat. In vel dui laoreet, commodo augue id, pulvinar lacus."
  62. >
  63. <img slot="media" src="https://cdn.framework7.io/placeholder/people-160x160-2.jpg" width="80" />
  64. </f7-list-item>
  65. <f7-list-item
  66. title="Billie Jean"
  67. after="$16"
  68. subtitle="Michael Jackson"
  69. text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sagittis tellus ut turpis condimentum, ut dignissim lacus tincidunt. Cras dolor metus, ultrices condimentum sodales sit amet, pharetra sodales eros. Phasellus vel felis tellus. Mauris rutrum ligula nec dapibus feugiat. In vel dui laoreet, commodo augue id, pulvinar lacus."
  70. >
  71. <img slot="media" src="https://cdn.framework7.io/placeholder/people-160x160-3.jpg" width="80" />
  72. </f7-list-item>
  73. </f7-list>
  74. <f7-block-title>Opposite Side</f7-block-title>
  75. <f7-list sortable sortable-opposite @sortable:sort="onSort">
  76. <f7-list-item
  77. title="1 Jenna Smith"
  78. after="CEO">
  79. <f7-icon icon="demo-list-icon" slot="media"></f7-icon>
  80. </f7-list-item>
  81. <f7-list-item
  82. title="2 John Doe"
  83. after="Director">
  84. <f7-icon icon="demo-list-icon" slot="media"></f7-icon>
  85. </f7-list-item>
  86. <f7-list-item
  87. title="3 John Doe"
  88. after="Developer">
  89. <f7-icon icon="demo-list-icon" slot="media"></f7-icon>
  90. </f7-list-item>
  91. <f7-list-item
  92. title="4 Aaron Darling"
  93. after="Manager">
  94. <f7-icon icon="demo-list-icon" slot="media"></f7-icon>
  95. </f7-list-item>
  96. <f7-list-item
  97. title="5 Calvin Johnson"
  98. after="Accounter">
  99. <f7-icon icon="demo-list-icon" slot="media"></f7-icon>
  100. </f7-list-item>
  101. <f7-list-item
  102. title="6 John Smith"
  103. after="SEO">
  104. <f7-icon icon="demo-list-icon" slot="media"></f7-icon>
  105. </f7-list-item>
  106. <f7-list-item
  107. title="7 Chloe"
  108. after="Manager">
  109. <f7-icon icon="demo-list-icon" slot="media"></f7-icon>
  110. </f7-list-item>
  111. </f7-list>
  112. </f7-page>
  113. </template>
  114. <script>
  115. export default {
  116. methods: {
  117. onSort(data) {
  118. // Sort data
  119. console.log(data);
  120. }
  121. }
  122. };
  123. </script>

← Smart Select

Stepper →