BY Ajay Singh22 May 2023 Edit
Popup Action button

Hello Everyone,

In this article, I will explain how to implement a PopupActionButton in WebAtoms with examples.

What you will learn?

  • You will learn how to implement the PopupActionButton on any of the pages.
  • How to display the menu item.
  • What action can be done using this component?

Why use it?

  • Generally, PopupActionButton is used in actionRenderer (a bindable property of the base page) to display some quick menu options.
  • On the basis of user selection, you can perform some actions or navigate to other pages.

How to write code?

<PopupActionButton
     icon="fa-solid fa-ellipsis-vertical">
      <div 
            style-width="80px" 
            data-click-event="none" 
            data-click-animate="no">
                <MenuItem
                    label="Add"
                    icon="fa-solid fa-add"
                    data-click-event="add-new"
                    />
                <MenuItem
                    label="Modify"
                    icon="fa-solid fa-edit"/>
                <MenuItem
                    label="Delete"
                    icon="fa-solid fa-trash-can" />
     </div>
</PopupActionButton>;

MenuItem is a function that takes some parameters like label, icon, event-click, href, target, etc.

How to navigate on the menu click?

In the above example, the data-click-event attribute calls the openAddNew function. Meaning it will navigate to add new training.

 @Action({ onEvent: 'add-new' })
  openAddNew() {
    PageNavigator.pushPage(AddNew);
  }

Code Explanation

  • We can set the label property to display the name of that menu.
  • We can associate an icon with the menu. In the above example, we have used the font awesome icon.
  • We can even set the eventClick to perform some action. In the above example, this.deleteTraining() is the method that would be executed on clicking the Delete menu item.
  • href property can be used to redirect to other pages.

Check out the StackBlitz Demo here.

Show more
BY Ajay Singh
1 Like
LikeCommentSave
LikeCommentSaveShare
1
May 23, 2023 - 6:58 AMLikeReply
Categories
General
YantraJS
Developer Guides
Tutorials
Web Atoms Updates

POPULAR POSTS
17 Mar 2021
LATEST ACTIVITY
Simmi Kava
commented this post.
Simmi Kava
liked this post.
Show more
ARCHIVES
2024
2023
2022
2021
TAGS
javascript (56)
developer (25)
javascriptdeveloper (16)
Xamarin.Forms (16)
Html (14)
typescript (12)
webatoms (12)
xamarin (11)
coding (10)
web-atoms (10)
arrays (9)
android (8)
javascript-developer (8)
csharp (7)
dotnet (7)
css (6)
update (6)
dotnet-standard (5)
function (5)
iOS (5)
methods (4)




Web Atoms: JSX (TSX + TypeScript) for Xamarin.Forms, Hot Reload Your App in Production Environment

PlaygroundSamples Repository