When I put this button in a form it starts a new line but I want it to say inline. I tried adding class="form-inline" but it doesn't work. I must be bad at searching online because I can't find the right answer myself.
What is the bootstrap convention to keep it inline?
<div class="col-sm-12">
<table>
<thead>
<tr>
<th>Edit</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a class="inline btn btn-info btn-xs glyphicon glyphicon-pencil"></a>
<button class="form-inline glyphicon glyphicon-trash btn btn-xs btn-danger del" type="button"></button>
</td>
</tr>
</tbody>
</table>
Fiddle
Just alter your markup a little:
Like this demo
<td>
<form class="form-inline" method="POST">
<a class="btn btn-info btn-xs glyphicon glyphicon-pencil"></a>
<button class="glyphicon glyphicon-trash btn btn-xs btn-danger del" type="button"></button>
</form>
</td>
Related
I don't know how to add dynamic content in my Vue js 2 app. I'd like to add many div elements after clicking on a button. THis div should have input and after clicking on a Save button all input texts inside dynamically created divs should be sent to backend (so I use model inside my template).
<div v-if="!this.spinnerVisibleForCorrectiveActions">
<div>
<table class="p-2 table-cell">
<tr class="font-weight-bold">
<td class="vue-good-table-col-200">
<div class="mt-2 criterion">
ID
</div>
</td>
<td class="vue-good-table-col-200">
<div class="mt-2 criterion">
DZIAŁANIE
</div>
</td>
<td class="vue-good-table-col-200">
<div class="mt-2">
SZCZEGÓŁY
</div>
</td>
</tr>
<tr v-for="(actions,index) in correctiveActions" :key="index">
<td class="vue-good-table-col-200">
<span> {{actions.orderNumber}}</span>
</td>
<td class="vue-good-table-col-200">
<span> {{actions.action}}</span>
</td>
<td class="vue-good-table-col-200">
<span> {{actions.recommendations}}</span>
</td>
</tr>
</table>
<button class="addAction p-3 mb-2 bg-secondary text-white w-100 bg-info btn btn-success">NAdd new action</button>
<br>
</div>
How to add dynamically (multiple times) something like this and additionally to have the possibility to get all data from my dynamically created inputs after clicking on a button:
<tr v-for="(actions,index) in correctiveActions" :key="index">
<td class="vue-good-table-col-200">
<span> {{actions.orderNumber}}</span>
</td>
<td class="vue-good-table-col-200">
<span> {{actions.action}}</span>
</td>
<td class="vue-good-table-col-200">
<span> {{actions.recommendations}}</span>
</td>
</tr>
Ok, the answer in my case is very simple - I have to only add an empty object to my correctiveActions array:
<button class="addAction p-2 mb-2 bg-secondary text-white w-100 bg-info btn btn-success" #click="addNewAction">Nowe
działanie
</button>
and next:
methods:{
addNewAction() {
this.correctiveActions.push
({
id: undefined,
incidentId: this.incidentId,
orderNumber: this.getNextOrderNumber(),
action: undefined,
recommendations: undefined
});
},
}
I have an array which i iterate with ngFor in the view as shown below.
I want to hide the button if all elements of y.errortyp are nottested.
How can i achieve this functionality? I tried some combinations of ngIf, but can not find a solution.
<...>
<tr *ngFor="let x of x">
<td> x.name</td>
<td *ngFor="let y of x.results">
<div *ngIf="y.errortyp == 'Error1'" class="red"></div>
<div *ngIf="y.errortyp == 'nottested'" class="grey"></div>
</td>
<td>
<button type="button" class="btn btn-default btn-lg btn-block" aria-label="Left Align"
(click)="download(x)">
Download
</button>
</td>
<...>
ive created a function that I can call on columns that I wish to sum up using the below. however the total (table total) entry for column 9 is always zero. the page total seems to work. and the page total and table total for column 9 works also.
"footerCallback": function ( row, data, start, end, display ) {
var api = this.api(), data;
// Remove the formatting to get integer data for summation
var intVal = function ( i ) {
return typeof i === 'string' ?
i.replace(/[\£,]/g, '')*1 :
typeof i === 'number' ?
i : 0;
};
var column_sum = function (col) {
// Total over all pages
total = api
.column(col)
.data()
.reduce( function (a, b) {
return intVal(a) + intVal(b);
}, 0 );
// Total over this page
pageTotal = api
.column(col, { page: 'current'} )
.data()
.reduce( function (a, b) {
return intVal(a) + intVal(b);
}, 0 );
return accounting.formatMoney(pageTotal) +' ('+ accounting.formatMoney(total) +' total)'
};
// Update footer
$( api.column(6).footer()).html(
column_sum(6)
);
$( api.column(9).footer()).html(
column_sum(9)
);
}
EDIT
I have added some sanitised data. currently the page total works for the first column and second columns.
The all pages total does not work. i.e each time I filter by the column header I should see the total across each page
<table width="100%" class="table table-striped table-bordered table-hover dataTable no-footer dtr-inline" id="circuit_list"
role="grid" style="width: 100%;">
<thead>
<tr>
<th>Info</th>
<th>Type</th>
<th>Cost PM</th>
<th>Term</th>
<th>Remaining Term</th>
<th>Remaining Cost</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="/circuits/edit/238/1/all_cl" class="btn btn-primary btn-circle">
<i class="fa fa-list"></i>
</a>
</td>
<td>Fibre</td>
<td>£950.00</td>
<td>12</td>
<td>0</td>
<td>£0.00</td>
</tr>
<tr>
<td>
<a href="/circuits/edit/238/2/all_cl" class="btn btn-primary btn-circle">
<i class="fa fa-list"></i>
</a>
</td>
<td>Fibre</td>
<td>£950.00</td>
<td>12</td>
<td>0</td>
<td>£0.00</td>
</tr>
<tr>
<td>
<a href="/circuits/edit/333/101/all_cl" class="btn btn-primary btn-circle">
<i class="fa fa-list"></i>
</a>
</td>
<td>MPLS</td>
<td>£1791.33</td>
<td>12</td>
<td>11</td>
<td>£19,704.63</td>
</tr>
<tr>
<td>
<a href="/circuits/edit/334/101/all_cl" class="btn btn-primary btn-circle">
<i class="fa fa-list"></i>
</a>
</td>
<td>MPLS</td>
<td>£100.00</td>
<td>12</td>
<td>11</td>
<td>£1,100.00</td>
</tr>
<tr>
<td>
<a href="/circuits/edit/235/1/all_cl" class="btn btn-primary btn-circle">
<i class="fa fa-list"></i>
</a>
</td>
<td>MPLS</td>
<td>£593.33</td>
<td>36</td>
<td>15</td>
<td>£8,899.95</td>
</tr>
<tr>
<td>
<a href="/circuits/edit/317/82/all_cl" class="btn btn-primary btn-circle">
<i class="fa fa-list"></i>
</a>
</td>
<td>Fibre</td>
<td>£103.00</td>
<td>3</td>
<td>0</td>
<td>£0.00</td>
</tr>
<tr>
<td>
<a href="/circuits/edit/229/2/all_cl" class="btn btn-primary btn-circle">
<i class="fa fa-list"></i>
</a>
</td>
<td>MPLS</td>
<td>£373.33</td>
<td>36</td>
<td>11</td>
<td>£4,106.63</td>
</tr>
<tr>
<td>
<a href="/circuits/edit/233/1/all_cl" class="btn btn-primary btn-circle">
<i class="fa fa-list"></i>
</a>
</td>
<td>DSL</td>
<td>£1837.66</td>
<td>60</td>
<td>6</td>
<td>£11,025.96</td>
</tr>
<tr>
<td>
<a href="/circuits/edit/234/1/all_cl" class="btn btn-primary btn-circle">
<i class="fa fa-list"></i>
</a>
</td>
<td>DSL</td>
<td>£373.34</td>
<td>36</td>
<td>15</td>
<td>£5,600.10</td>
</tr>
<tr>
<td>
<a href="/circuits/edit/243/5/all_cl" class="btn btn-primary btn-circle">
<i class="fa fa-list"></i>
</a>
</td>
<td>DSL</td>
<td>£373.34</td>
<td>36</td>
<td>15</td>
<td>£5,600.10</td>
</tr>
<tr>
<td>
<a href="/circuits/edit/244/4/all_cl" class="btn btn-primary btn-circle">
<i class="fa fa-list"></i>
</a>
</td>
<td>MPLS</td>
<td>£373.34</td>
<td>36</td>
<td>12</td>
<td>£4,480.08</td>
</tr>
<tr>
<td>
<a href="/circuits/edit/324/83/all_cl" class="btn btn-primary btn-circle">
<i class="fa fa-list"></i>
</a>
</td>
<td>4G</td>
<td>£103.00</td>
<td>3</td>
<td>0</td>
<td>£0.00</td>
</tr>
<tr>
<td>
<a href="/circuits/edit/2/6/all_cl" class="btn btn-primary btn-circle">
<i class="fa fa-list"></i>
</a>
</td>
<td>4G</td>
<td>£41.50</td>
<td>12</td>
<td>0</td>
<td>0.00</td>
</tr>
<tr>
<td>
<a href="/circuits/edit/57/18/all_cl" class="btn btn-primary btn-circle">
<i class="fa fa-list"></i>
</a>
</td>
<td>4G</td>
<td>£45.00</td>
<td>12</td>
<td>0</td>
<td>£0.00</td>
</tr>
<tr>
<td>
<a href="/circuits/edit/113/35/all_cl" class="btn btn-primary btn-circle">
<i class="fa fa-list"></i>
</a>
</td>
<td>Fibre</td>
<td>£45.00</td>
<td>12</td>
<td>0</td>
<td>£0.00</td>
</tr>
<tr>
<td>
<a href="/circuits/edit/218/71/all_cl" class="btn btn-primary btn-circle">
<i class="fa fa-list"></i>
</a>
</td>
<td>4G</td>
<td>£57.00</td>
<td>12</td>
<td>0</td>
<td>£0.00</td>
</tr>
<tr>
<td>
<a href="/circuits/edit/264/71/all_cl" class="btn btn-primary btn-circle">
<i class="fa fa-list"></i>
</a>
</td>
<td>MPLS</td>
<td>£45.00</td>
<td>12</td>
<td>0</td>
<td>£0.00</td>
</tr>
<tr>
<td>
<a href="/circuits/edit/269/61/all_cl" class="btn btn-primary btn-circle">
<i class="fa fa-list"></i>
</a>
</td>
<td>DSL</td>
<td>£45.00</td>
<td>12</td>
<td>0</td>
<td>£0.00</td>
</tr>
<tr>
<td>
<a href="/circuits/edit/300/85/all_cl" class="btn btn-primary btn-circle">
<i class="fa fa-list"></i>
</a>
</td>
<td>4G</td>
<td>£30.00</td>
<td>12</td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>
<a href="/circuits/edit/307/76/all_cl" class="btn btn-primary btn-circle">
<i class="fa fa-list"></i>
</a>
</td>
<td>4G</td>
<td>£45.00</td>
<td>12</td>
<td>6</td>
<td>270.00</td>
</tr>
</tbody>
</table>
Most probably in one or more of the cells for column 9, the value there fails to convert to a number and you are getting a NaN returned by intVal function.
There are 2 issues in intVal:
line i.replace(/[\£,]/g, '')*1 can return NaN
typeof i === 'number' can be true for NaN
From what it seems, intVal is trying to check for this, but the logic is wrong.
change the intVal to:
var intVal = function ( i ) {
if(typeof i === 'string') {
i = i.replace(/[\£,]/g, '')*1;
}
// check if you got a valid number.
if (Number.isNaN(i)) {
return 0;
}
return i;
};
If the filtered total is needed, use:
total = api.column(col, {"filter": "applied"})
or
total = api.column(col, {"search": "applied"})
Is it possible for selenium to find a label element by its "for" attribute using xpath?
I'm testing a site that has 7 yes or no questions in row. The way the CSS is done, you click on the label instead of the input radio button. Normally I'd just find the element by text content, but there is a yes and no for each question.
I'm thinking that a work-around would be to do a javascript click on the input button to get around the "element is not visible" error that I get when trying to .click() the input directly, but I wanted to see if there was a better way to locate the label which is what users would actually be clicking.
*Edit for all of your who can't remember what a label element looks like. How would you select the middle one from this group?
<label for="superLongSetOfRandomCharacters123" class="common-to-all-buttons"> No </label>
<label for="superLongSetOfRandomCharacters345" class="common-to-all-buttons"> No </label>
<label for="superLongSetOfRandomCharacters456" class="common-to-all-buttons"> No </label>
More specifically, this is how they sit in the DOM
<ul class="list-view list-view-dividers">
<li class="list-view-item">
<div class="content">
<div id="variableValue1" class="multipleChoice">
<div class="form-row">
<label>Question 1</label>
<div class="form-row">
<table class="choices" id="randomlyGenerated-1">
<tbody>
<tr>
<td>
<div class="ui-radio"><label for="randomlyGenerated1" class="ui-btn ui-corner-all ui-btn-inherit ui-btn-icon-left ui-radio-off"> Yes</label><input id="randomlyGenerated1" type="radio" name="randomlyGenerated1" value="Yes"></div>
</td>
<td>
<div class="ui-radio"><label for="randomlyGenerated2" class="ui-btn ui-corner-all ui-btn-inherit ui-btn-icon-left ui-radio-off"> No</label><input id="randomlyGenerated2" type="radio" name="randomlyGenerated2" value="No"></div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div id="randomlyGenerated1-Error" class="component-error"></div>
</div>
</div>
</li>
<li class="list-view-item">
<div class="content">
<div id="variableValue2" class="multipleChoice">
<div class="form-row">
<label>Question 2</label>
<div class="form-row">
<table class="choices" id="randomlyGenerated-2">
<tbody>
<tr>
<td>
<div class="ui-radio"><label for="randomlyGenerated21" class="ui-btn ui-corner-all ui-btn-inherit ui-btn-icon-left ui-radio-off"> Yes</label><input id="randomlyGenerated21" type="radio" name="randomlyGenerated21" value="Yes"></div>
</td>
<td>
<div class="ui-radio"><label for="randomlyGenerated22" class="ui-btn ui-corner-all ui-btn-inherit ui-btn-icon-left ui-radio-off"> No</label><input id="randomlyGenerated22" type="radio" name="randomlyGenerated22" value="No"></div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div id="randomlyGenerated2-Error" class="component-error"></div>
</div>
</div>
</li>
</ul>
It works for selecting all labels with target 'for':
label[#for='superLongSetOfRandomCharacters123']
or you can leave #for='' blank for selecting all labels with any values (i.e. label[#for])
I guess, the XPath-Option you are looking for would be "#". so in your case something like [...]/label/#for would return you that for-value, which you could then use to check where you are ;)
Cheers
D
Use find_element_by_xpath
label = self.browser.find_element_by_xpath('//label[#for="id_field"]')
I am working in asp.net mvc4 with Razor View. I am using angularJs with it. But in partial view angularJs is not working.
Here is my view code:
#using (Html.BeginForm("Create", "Requisition", FormMethod.Post, new { id = "RequisitionForm", ng_app = "" }))
{
#Html.ValidationSummary(true)
<div class="divSection">
<div class="divBox divSectionLeftLeft">
<label>Product</label>
</div>
<div class="divBox divSectionLeftRight">
<input type="text" id="ProductName" name="ProductName" ng-model="newItem.ProductName" />
</div>
<div class="divBox divSectionRightLeft">
<label>Quantity</label>
</div>
<div class="divBox divSectionRightRight">
<input type="text" id="Quantity" name="Quantity" ng-model="newItem.Quantity" />
</div>
</div>
<div class="divClear">
</div>
<div class="ContainerRowButton">
<button type="button" class="btn btn-primary btn-mini" ng-click="items.push(newItem); newItem={}">Add Req-Detail</button>
</div>
<div style="width: 800px; height: 160px; overflow-y: scroll">
<table class="table table-striped table-bordered" id="RequisitionDetailsTbl" ng-init="items=[]">
<thead>
<tr>
<th>Product
</th>
<th>Quantity
</th>
<th>Action</th>
</tr>
</thead>
<tr ng-hide="items.length">
<td colspan="3">No Requisition Added Yet. . .</td>
</tr>
<tbody ng-repeat="item in items">
<tr>
<td>{{item.ProductName}}
</td>
<td>{{item.Quantity | number:2}}
</td>
<td>
<button type="button" id="delReqDetail" ng-click="items.splice($index, 1);" class="btn btn-primary btn-mini">Delete</button>
</tr>
</tbody>
</table>
</div>
}
My _Layout is like this:
#Styles.Render("~/Content/css")
#Scripts.Render("~/bundles/jquery, ~/bundles/jqueryui, ~/bundles/others")
Here "~/bundles/others" contains the angular.js.
I am not getting any error in firebug console. What wrong am I doing?
One more thing I am showing the partialview in popup window. The code Works fine if I don't use it in popup window.