Modal popup on button click - Semantic UI - html

Hello I've recently been trying to get the modals working with Semantic-UI But I can't seem to get it to work how I want it to. I want to make it so that when a user clicks a specific menu on the sidebar a modal will pop up on the page where a user can input text. If anyone knows how to go about doing this please comment below! Thanks
<a class="item">
<i class="money icon"></i>
Free Coins
</a>
Thanks to anyone that can help!

Change <a class="item"> to <a class="item" id="coins">
jquery:
<script type="text/javascript">
$(document).ready(function(){
$('#coins').click(function(){
$('#modalid').modal('show');
});
});
</script>
Note: #modalid is your modal div id.
Hope this will work.

$('#myModal').modal('attach events', 'a.item', 'show');

<div class="ui container">
//model start
<div class="ui basic modal">
<div class="ui icon header">
<i class="archive icon"></i>
Archive Old Messages
</div>
//content in model
<div class="content">
<p>Your inbox is getting full, would you like us to enable automatic archiving of old messages?</p>
</div>
//actions in the model(buttons)
<div class="actions">
<div class="ui red basic cancel inverted button">
<i class="remove icon"></i>
No
</div>
<div class="ui green ok inverted button">
<i class="checkmark icon"></i>
Yes
</div>
</div>
</div>
//model ends
//Button to click to pop up the model
<div class="ui button">
<i class="remove"></i>
delete
</div>
</div>
//script
<script>
$('.ui.button').click(function(){
$('.ui.basic.modal').modal('show');
});
</script>

Related

Pure CSS accordion stop anchor page scroll

I have a pure CSS accordion, it works great, but an issue is handling click shifting the screen up to the anchor tag;
<div class="collapse-content">
<div class="collapse" id="instagram">
<a class="instagram" href="#instagram" onClick="return false;"><i class="fab fa-instagram"></i>Insta</a>
<div class="content">
<div class="inner-content">
Insta content
</div>
</div>
</div>
<div class="collapse" id="twitter">
<a class="twitter" href="#twitter"><i class="fab fa-twitter"></i>Twitter</a>
<div class="content">
<div class="inner-content">
Twitter content
</div>
</div>
</div>
<div class="collapse" id="dribbble">
<a class="dribbble" href="#dribbble"><i class="fab fa-dribbble"></i>Dribble</a>
<div class="content">
<div class="inner-content">
Dribble content
</div>
</div>
</div>
</div>
How can I suppress the browser scrolling the anchor to the top of the screen? I've tried adding a ? ! and 0 to the end of the anchor, but that breaks the link from working and as you can see above I've tried onClick="return false;" which stops the click. I'm guessing what I need is some sort of offset, as I don't want to suppress the click event just the scrolling too.
# the moment I'm avoiding using Jquery, ideally no JS but trying to keep it as simple as possible.
If these aren't links, then you shouldn't be using <a> tags. Links can:
link to another document
link to another part of the same document
In this case, clicking triggers an action, you should use a <button type="button"> tag.

Semantic UI: How is it possible to left align an action item?

I'm trying to add a left aligned button to a Semantic UI modal within the actions region, through using a container element, and I uploaded a sample on jsfiddle in order to give more details about the code:
<div id="modal" class="ui modal">
<i class="close icon"></i>
<div class="header">
Title
</div>
<div class="actions">
<div class="ui left aligned container">
<div class="ui button">
<i class="eraser icon"></i>
Clear
</div>
</div>
<div class="ui black deny button">
Cancel
</div>
<div class="ui approve positive right labeled icon button">
Submit
<i class="checkmark icon"></i>
</div>
</div>
</div>
However, the container doesn't well apply the alignment: while the button gets left aligned, it loses its vertical alignment with other action items.
I have not found any method on implementing the alignment, despite having read the Semantic UI documentation.
Any help will be greatly appreciated.
Add float: left on the left-aligned-container
.left-aligned-container {
float: left;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.3.1/semantic.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.3.1/semantic.css">
<div id="modal" class="ui modal">
<i class="close icon"></i>
<div class="header">
Title
</div>
<div class="actions">
<div class="ui left-aligned-container">
<div class="ui button">
<i class="eraser icon"></i> Clear
</div>
</div>
<div class="ui black deny button">
Cancel
</div>
<div class="ui approve positive right labeled icon button">
Submit
<i class="checkmark icon"></i>
</div>
</div>
</div>
<script>
$('#modal').modal('show')
</script>

Dismiss a ui dropdown in semantic

I need to dismiss a ui dropdown while hovering over it. Now, the ui drop down is just visible and never shows or hides when tapped or clicked.
Here are the snippets:
<div ng-show="user" class="ui pointing dropdown link item">
<span class="text">Reg</span>
<i class="dropdown icon"></i>
<div class="menu transition visible">
<a class="item" href="/xyz">
Schools
</a>
<div class="divider"></div>
<a class="item" href="/xyz2">
Admissions
</a>
</div>
</div>
UI drop down is initialized like this:
<script src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.3.1/components/dropdown.js" type="text/javascript"></script>
<script type="text/javascript">
$('.ui.dropdown')
.dropdown();
</script>
What changes are needed here?
You just need to add the css class simple for hover.
<div ng-show="user" class="ui pointing simple dropdown link item">
<span class="text">Reg</span>
<i class="dropdown icon"></i>
<div class="menu transition visible">
<a class="item" href="/xyz">
Schools
</a>
<div class="divider"></div>
<a class="item" href="/xyz2">
Admissions
</a>
</div>
</div>
And in JS file ,you need to initialize like below
<script>
$(document).ready(function () {
$('.ui.dropdown').dropdown();
})
</script>

SemanticUI pointing dropdown does not work correctly in Angular 2

I as trying to make a pointing drop down, and it is as Semantic UI's documentation says it should be, but it didn't open to the side when I click,I might be missing something, can you guys help me?
<pre>
<div class="ui vertical menu">
<div class="header item">
Exemplos
</div>
<div class="ui left pointing dropdown link item">
<i class="dropdown icon"></i>
Imagem
<div class="menu">
<div class="item" routerLink="images"
RouterLinkActive="active">Reconhecimento de Objetos</div>
<div class="item">Reconhecimento Facial</div>
</div>
</div>
</div>
</pre>
The Semantic UI dropdown module requires some JavaScript for it to work properly. To just get the menu to show, you can use angular to perform the necessary Javascript work.
<div class="ui vertical menu">
<div class="header item">
Exemplos
</div>
<div class="ui left pointing dropdown link item" ngClass="{'visible': showMenu, 'active': showMenu}">
<i class="dropdown icon" (click)="showMenu = !showMenu"></i>
Imagem
<div class="menu" ngClass="{'visible': showMenu, 'hidden': !showMenu}">
<div class="item" routerLink="images"
RouterLinkActive="active">Reconhecimento de Objetos</div>
<div class="item">Reconhecimento Facial</div>
</div>
</div>
</div>
This won't apply the classes with the proper timing though to do the animations that Semantic UI provides as well. To do that you will have to load the requisite js libraries(jQuery and semantics js files) and get them to play nicely with Typescript.

SemantiUI: Sidebar flyout menu

I am trying to get a Fly-out type menu launched from a sidebar. Any ideas/examples? Wondering if Popups are an option?
Ex: When user has their mouse over the settings icon, I want a menu to "fly-out" with the 3 options..,
<div id="mnuSideNav" class="ui vertical menu labeled icon inverted sidebar">
<div id="mnuAdmin" class="item ">
<i class="settings icon" title="Administrative Settings"></i>
<div id="mnuAdminItems" class="inverted menu">
<a class="item"><i class="edit icon"></i> Edit Profile</a>
<a class="item"><i class="globe icon"></i> Choose Language</a>
<a class="item"><i class="settings icon"></i> Account Settings</a>
</div>
</div>
</div>
Resolved this using a popup..,
Elements like that support overflow cannot have menus extend beyond the sidebar ("Fly-out"). So Pop-ups are the only option. Define a popup and in the javascript initializing the popup set its popup parameter..,
Ex: SideBar:
<div id="mnuSideNav" class="ui left vertical menu labeled icon inverted sidebar">
<a id="sbAdmin" class="browse item popupMenu">
<i class="settings icon" title="Administrative Settings"></i>
</a>
</div>
Popup
<div id="adminPopup" class="ui popup ">
<div class="ui one column relaxed equal height left aligned grid ">
<div class="ui column ">
<h4 class="ui header">Admin Menu</h4>
</div>
</div>
</div>
Script:
$('.popupMenu').popup({
popup: '#adminPopup',
inline : true,
hoverable: true,
position : 'right center',
delay: {show: 300, hide: 800}
});