このページのトップへ
コンテキストメニュー付きリピーター

コンテキストメニュー付きリピーター

リピーターの各アイテムにコンテキストメニューを追加する

中級.png

上級

4K

出版された:

May 19, 2021

酒を楽しむ少女

によって

アンカー 1
開発者を雇う

説明例

In this example, we added a context menu to each item in a repeater. When site visitors click a button in an item, a container box with menu choices appears under the clicked button, simulating the appearance of a dropdown menu. Site visitors can then click a menu choice to perform an action, such as editing the item’s text or deleting the item.

コード例

タブ1

.

タブ2

.

タブ3

.

このコードによる解決は複雑になる可能性がある。

どのように構築したか


ページ要素


First we added a repeater to our page. Then we attached the following elements to the repeater:


  • Text elements: For displaying text in each item

  • Quick Actions button: Clicking it opens the context menu

  • Text input: For editing the title of the repeater item

  • Icon button: For applying the edited text to the title


The context menu is not part of each repeater item, but rather a single container box that is dynamically positioned under the specific Quick Actions button that was clicked. The menu includes the following elements:


  • Edit Item button: Clicking it allows site visitors to edit the repeater item’s title

  • Delete Item button: Clicking it deletes the current item from the repeater



コード


Our code does the following:


  1. When the page loads, show a preloader by switching to the ‘loader’ state of a multi-state box.

  2. Load data into the repeater using the getDataFromBackend function and switch to the ‘withData’ state of a multi-state box.

  3. If a Quick Actions button is clicked, calculate the position of the current repeater item and display the context menu under the Quick Actions button using the wix-animations API.

  4. If a site visitor clicks the Edit Item button, show the text input element, allowing the site visitor to edit the title. Hide the input after the visitor clicks the icon button for applying the edit. Hide the context menu.

  5. If a site visitor clicks the Delete Item button, delete the item. Hide the context menu.

使用したAPI

コード以外の例。

コード以外の例。

コード以外の例。

コード以外の例。

コード以外の例。

コード以外の例。

関連記事

記事リンク

開発者を雇う

Veloソリューションは強力なツールですが、自力で構築するのは困難です。経験豊富なVelo開発会社に構築をお任せください。

関連例

これは役に立ったか?

はい

|

いいえ

ご意見ありがとう!

Repeater Context

Repeater Context

Change a specific item in a repeater when a site visitor interacts with it

中級.png

初心者

タブ

タブ

Create tabs using a multi-state box

中級.png

初心者

Preloader for File Upload

Preloader for File Upload

Display a preloader while a file is uploading

中級.png

初心者

アンカー2
ページ下