drop down list not getting updated on selection change - model-view-controller

PFB my code. I have designed a drop down list using bootstrap in asp.net mvc. The contents of the list are static and hard coded. When selection is changed in drop down, the latest item is not updated. I am attaching my code as well as the screenshot of the issue. In drop down list, even if I select Assigned, the status list is not getting updated.
the status field is not changing to assigned or in progress<div class="dropdown">
<button class="btn btn-default dropdown-toggle" runat="server" type="button" id="dropdownStatus" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
Status
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownStatus">
<li>Assigned</li>
<li>In Progress</li>
<li>Resolved</li>
</ul>
</div>

You'll have to use Javascript to update the model if you use a bootstrap dropdown. Just keep a hidden for on the page, then attach a handler to the dropdown's change.
One thing to note is that Bootstrap dropdowns don't fire a change event. You'll have to attach handlers to the individual items. Something like this:
$('.dropdown-menu a').click(function(e) {
// set the hidden field to the new value
var newValue = $(this).text();
$('#foo').val(newValue);
});
#Html.HiddenFor(m => m.myProperty, new {id = "foo"})
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" runat="server" type="button" id="dropdownStatus" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
Status
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownStatus">
<li>Assigned</li>
<li>In Progress</li>
<li>Resolved</li>
</ul>
</div>
Of course, if you don't really need a Bootstrap dropdown, and perhaps only need it to look like it, you could do it very easily by just using a regular HTML dropdown and styling it like a bootstrap dropdown:
#Html.DropDownListFor(m => m.myProperty, new {#class = "form-control"})
form-control is a bootstrap css class that makes your input controls more Bootstrap-like. It's not exactly the same though (although I like it better), so the choice will be up to you.

Related

Buttons BackPack Laravel

I need some help on the backpack, the buttons.
I have a list of products, and in the edit and delete buttons I have added two more to the nutrient of a product and its price. Using the backpack I do not know how to load the id of the product in question to put this additional information. How can I do it?
Image
Inside the button view you created you should be able to use $entry. Check out https://laravel-backpack.readme.io/docs/crud-buttons for more info.
Even though this event happened more than 1 month, I'll try to share some information to help others.
1. First of all you need to create a new blade file
resources\views\vendor\backpack\buttons\crud\buttons.
2. Inside of your file
<i class='fa fa-list'></i>Listar Nutrientes
The $entry->getKey() is going to provide the "id" to you.
3. Connecting the "Button" to your CrudCrontroller
Inside your ProductCrudController you need to add a new entry.
$this->crud->addButtonFromView('line', 'extra_button', 'extra_button', 'beginning');
the extra_button "just a example" needs to have the name of your blade file in the third parameter "if i'm not wrong".
After this you should get your new button for each line listed in the table.
Just a tip: If you're going to add "a lot of buttons" try to use a
drop down button.
<div class="btn-group">
<button type="submit" class="btn btn-primary btn btn-xs btn-default">
<span class="fa fa-list" role="presentation" aria-hidden="true" style="color: #f1f1f1"></span>
<span data-value="save_and_back" style="color: #fff">Opções</span>
</button>
<button type="button" class="btn btn-primary dropdown-toggle btn-xs btn-default" data-toggle="dropdown" aria-haspopup="true" aira-expanded="false" aria-expanded="true">
<span class="caret"></span>
<span class="sr-only">▼</span>
</button><div class="dropdown-backdrop"></div>
<ul class="dropdown-menu" style="font-size: 12px;">
<li><i class='fa fa-plus'></i>Add new nutriente</li>
<li><i class='fa fa-list'></i>Listar nutrientes</li>
<li><i class='fa fa-arrow-right'></i>Second Action</li>
<li><i class='fa fa-times'></i>Cancel</li>
</ul>
</div>

How to make dropdown items "clickable" by enter button?

I'm developing an app with Angular and Semantic-UI.
I have a dropdown menu like the following: https://plnkr.co/edit/BTCxfk
<div class="ui right labeled top pointing floating icon button dropdown">
<i class="icon folder open"></i>
<span class="text">Menu</span>
<div class="menu">
<div class="item" (click)="onClickItem()" *ngFor="#m of menu">
<i class="icon sign in"></i>
{{m}}
</div>
</div>
</div>
I would like to have that users can click on a single item using tab and enter buttons.
As you can see they can only move towards menu items, but they can't trigger the click event.
Any idea?
I would give this item a tab-index of 0 since most elements like this aren't tabbable by default.
<div class="ui right labeled top pointing floating icon button dropdown">
<i class="icon folder open"></i>
<span class="text" tabindex="0" role="menu">Menu</span>
<div class="menu">
<div class="item" (click)="onClickItem()" *ngFor="#m of menu">
<i class="icon sign in"></i>
{{m}}
</div>
</div>
</div>
I added tab index of 0 and role of menu.

Dropdown Toggle Firing Twice When Clicked - Bootstrap 4 Alpha 6

I'm trying to use a basic dropdown like so...
<div class="dropdown"> <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> Dropdown button </button> <div class="dropdown-menu" aria-labelledby="dropdownMenuButton"> <a class="dropdown-item" href="#">Action</a> <a class="dropdown-item" href="#">Another action</a> <a class="dropdown-item" href="#">Something else here</a> </div> </div>
But it wasn't working. So I googled around and added this to my index...
<script>window.__theme = 'bs4';</script>
Still nothing. Thinking I wasn't including something correctly, I placed a breakpoint in the bootstrap.js at the first line in the dropdown toggle....
Dropdown.prototype.toggle = function toggle() { if (this.disabled || $(this).hasClass(ClassName.DISABLED)) {
To my surprise, I was actually hitting this breakpoint. To my greater suprise I was hitting this breakpoint twice. With one click, it opens the dropdown, only visibile because of hitting the breakpoint a second time, and when I continue it toggles the dropdown closed. So in actuality it is toggling every time I click it, but it is toggling twice so fast that it opens and closes before I can see it, seeming to not work at all.
Is this a known issue or is there a fix for this?

Selenium Firefox span tag

I'm having a problem with selecting an element by linkText which is located in a span. In Chrome it works perfectly but in Firefox it doesn't for some reason and i can't understand it for hours already. I'm trying to locate the element as follows: login.wait.until(ExpectedConditions.elementToBeClickable(By.linkText("Kassa"))).click(); However it simply doesn't find it. I noticed that all other elements that are located in the upper navigation bar and the text isn't in a span tag it finds easley, however thous that are in the span it can't find. What is the difference and what is the best way to reach to that element. Because in this case finding by linkText seems to be perfect. Thank you! HTML attached:
<nav class="site-navbar navbar navbar-inverse navbar-fixed-top bg-teal-600" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
<div class="navbar-brand site-gridmenu-toggle" data-toggle="gridmenu">
<span class="navbar-brand-text">whatever</span>
</div>
<button type="button" class="navbar-toggle hamburger hamburger-close collapsed" data-target="#site-navbar-collapse" data-toggle="collapse">
<i class="hamburger-bar" aria-hidden="true"></i>
</button>
<button type="button" class="navbar-avatar navbar-toggle padding-horizontal-0" data-toggle="dropdown" href="#" aria-expanded="false" data-animation="scale-up" role="button">
<span class="avatar avatar-online" style="top: -3px">
<img src="https://whatever.png" alt="..."> <i></i>
</span>
</button>
<a type="button" href="https://whatever" class="navbar-toggle padding-top-15 padding-horizontal-0">
<span class="btn btn-warning"> Kassa </span>
</a>
Code snippet:
System.setProperty("webdriver.gecko.driver","C:\\Utility\\BrowserDrivers\\geckodriver.exe");
driver = new FirefoxDriver();
wait = new WebDriverWait(driver, 10);
driver.manage().window().maximize();
Then i'm going to the webpage, through basic authentication , won't post this data here and basically on the page that i land i want to try to find the element like that:
login.wait.until(ExpectedConditions.elementToBeClickable(By.linkText("Kassa"))).click();
Picture of the nav. bar nav. bar
Although if a certain code works on chrome it should work on firefox as well; but if it isn't working then you can try to find the said element using following :
UPDATED:
WebElement navElement = driver.findElement(By.cssSelector("div.container-fluid a>span.btn.btn-warning"));
Actions action = new Actions(driver);
action.moveToElement(navElement).click().build().perform();

How to bind dropdown list with collection in adobe CQ5..?

i'm new in Adobe CQ5, i'm developing a training project, here my requirement for binding a Dropdown list using Dialog, there author can add multiple item, and these item should be display in dropdown list, so how to do this,
i create a component with dialog
i assigned field what i need & also give an property as text field i'm able to bind it but i want to use them as collection
my code for component.jsp is:
<%#include file="/libs/foundation/global.jsp"%>
<%#page import="java.util.Iterator,com.day.text.Text,com.day.cq.wcm.api.Page,com.day.cq.wcm.foundation.Image,com.day.cq.commons.Doctype" %>
<div class="main-container">
<div class="hero-dropdown-container">
<div class="dropdown">
<button aria-expanded="false" data-toggle="dropdown" id="dropdownMenu1" type="button" class="menu-black-arrow btn btn-default status dropdown-toggle"><%= properties.get("itemText") %></button>
<ul aria-labelledby="dropdownMenu1" role="menu" class="dropdown-menu">
<li role="presentation"><a tabindex="-1" role="menuitem" href='<%= properties.get("itemValue") %>'><%= properties.get("itemText") %></a></li>
<li role="presentation"><a tabindex="-1" role="menuitem"><%= properties.get("itemValue") %></a></li>
<li role="presentation"><a tabindex="-1" role="menuitem">Something else here</a></li>
<li role="presentation"><a tabindex="-1" role="menuitem">Separated link</a></li>
</ul>
</div>
</div>
</div>
Since you need to associate itemText and itemValue the required xtype would be compositefield. But it doesn't work for multiple rows. The multifield xtype that's supposed to work with multiple rows doesn't work with a compositefield. What you will have to do is write a multi-compositefield.
Method to do this well documented on stackoverflow and adobe forums , few links :
https://helpx.adobe.com/experience-manager/using/creating-custom-xtype.html
Multifield component issue
However there are few open source solutions for this :
http://adobe-consulting-services.github.io/acs-aem-commons/features/widgets.html#multi-field-panel-since-150
https://github.com/Citytechinc/multicomposite-addon

Resources