I need to create a {{linkTo}} that wraps around an entire table-row, but it does not allow me to use {{linkTo}} if there are any non-ember DOM elements in between {{#linkTo}} and {{/linkTo}}
When I put linkTo directly around {{Name}} , like in the code below, it works
{{#each}}
<tr class="people-list">
<td>
<input type="checkbox" class="toggle">
<label class="category-text">
{{#linkTo 'category' this}}
{{Name}}
{{/linkTo}}
</label>
<img class="table-img" src="images/x.png">
<img class="table-img" {{action 'edit'}} src="images/pencil-grey.png">
{{/linkTo}
</td>
</tr>
{{/each}}
but when I try to extend those links to outside of the , like shown below, the linkTo doesn't work at all.
{{#each}}
{{#linkTo 'category' this}}
<tr class="people-list">
<td>
<input type="checkbox" class="toggle">
<label class="category-text">
{{Name}}
</label>
<img class="table-img" src="images/x.png">
<img class="table-img" {{action 'edit'}} src="images/pencil-grey.png">
</td>
</tr>
{{/linkTo}
{{/each}}
Instead of using {{#linkTo}}, you can get this result by calling an action which redirects to a different route:
{{#each}}
<tr class="people-list" {{action 'goTo' this}}>
<td>
<input type="checkbox" class="toggle">
<label class="category-text">
{{Name}}
</label>
<img class="table-img" src="images/x.png">
<img class="table-img" {{action 'edit'}} src="images/pencil-grey.png">
</td>
</tr>
{{/each}}
And then on your controller:
actions: {
goTo : function(input){
this.transitionToRoute('category', input);
}
}
why don't you use a view with tagName='tr', and in the click event redirect to the route you want ? something like this:
App.LinkToCategory = Ember.View.extend({
classNames: ['people-list'],
tagName: 'tr',
click: function() {
router.transitionTo('category', category)
}
})
and in your template something like this:
{{#view App.LinkToCategory category=this}}
<td>
<input type="checkbox" class="toggle">
<label class="category-text">
{{Name}}
</label>
<img class="table-img" src="images/x.png">
<img class="table-img" {{action 'edit'}} src="images/pencil-grey.png">
</td>
{{/view}}
I didn't check if it works, but you got the idea.
The link-to helper accepts a tagName property, so you can make the element that does the linking the tr itself.
{{#each}}
{{#linkTo "category" this tagName="tr" class="people-list" role="link"}}
<td>
<input type="checkbox" class="toggle">
<label class="category-text">
{{Name}}
</label>
<img class="table-img" src="images/x.png">
<img class="table-img" {{action "edit" bubbles=false}} src="images/pencil-grey.png">
</td>
{{/linkTo}
{{/each}}
You may also need to add bubbles=false to your edit button, so that clicking it doesn't follow the link. And because the "link" is not an a element, I've also added the role="link" attribute so it is accessible to screen readers.
Related
I'd like to select the checkbox based on the user email. I try somethig like this but doesn't work: "InvalidStateError: An exception was thrown debugger eval code:1".
$x("//span[text()='my.user#mydomain.com']/parent::div/previousElementSibling::td");
What am I doing wrong? Thanks!
<td class="col checkUser selection">
<div class="checkbox um-checkbox">
<input type="checkbox" value="option1">
<label data-select-checkbox="" data-ngretain="u-cd324c08-f215-5784-87b7-98944b18819f"></label>
</div>
</td>
<td class="col userData item-collapse item-top">
<div class="showUserDetails" title="My User" data-id="u-cd324c08-f215-5784-87b7-98944b18819f">
<span class="text-overflow " style="max-width: 90%;display: inline-block;">
<span class="first-name">My </span>
<span class="first-name">User </span>
</span>
<span>
<img style="height: 24px;width:24px;margin-left: 5px;" src="/Admin/img/admin-gray.svg">
</span>
</div>
</td>
<td class="col userData item-collapse item-top">
<div class="showUserDetails text-overflow" title="my.user#mydomain.com" data-id="u-cd324c08-f215-5784-87b7-98944b18819f">
<span class="first-name">my.user#mydomain.com </span>
</div>
</td>
previousElementSibling is not a XPath selector but a property on a element: https://developer.mozilla.org/en-US/docs/Web/API/NonDocumentTypeChildNode/previousElementSibling
An almost similar selector for a XPath is the preceding-sibling selector. But that will return all the preceding siblings so you will have to maximize the result to 1 with the [1] selector:
/preceding-sibling::div[1]
And then you still need to only select the divs containing the checkbox class so you will need the [contains(#class, 'checkbox')] selector and select the input with the /input selector.
The complete selector for the checkbox then looks like this:
$x("//span[text()='my.user#mydomain.com']/parent::div/preceding-sibling::div[contains(#class, 'checkbox')][1]/input")
If however you are using document.evaluate instead of $x you will need to replace the text()='the text' selector with the contains(. ,'the text') selector because the text() selector does not work in the document.evaluate method.
The complete executable code snippet:
var doc = document.children[0].children[1];
var checkbox = document.evaluate(
"//span[contains(., 'my.user#mydomain.com')]/parent::div/preceding-sibling::div[contains(#class, 'checkbox')][1]/input",
doc,
null,
XPathResult.ANY_TYPE,
null
).iterateNext()
console.log(checkbox)
alert(checkbox)
<td class="col checkUser selection">
<div class="checkbox um-checkbox">
<input type="checkbox" value="option1">
<label data-select-checkbox="" data-ngretain="u-cd324c08-f215-5784-87b7-98944b18819f"></label>
</div>
</td>
<td class="col userData item-collapse item-top">
<div class="showUserDetails" title="My User" data-id="u-cd324c08-f215-5784-87b7-98944b18819f">
<span class="text-overflow " style="max-width: 90%;display: inline-block;">
<span class="first-name">My </span>
<span class="first-name">User </span>
</span>
<span>
<img style="height: 24px;width:24px;margin-left: 5px;" src="/Admin/img/admin-gray.svg">
</span>
</div>
</td>
<td class="col userData item-collapse item-top">
<div class="showUserDetails text-overflow" title="my.user#mydomain.com" data-id="u-cd324c08-f215-5784-87b7-98944b18819f">
<span class="first-name">my.user#mydomain.com </span>
</div>
</td>
I am trying to show product items into shopping cart when i click add to card button how to fix it error? Call to undefined function Gloudemans\Shoppingcart\array_get()
https://flareapp.io/share/B5ZeYg7o#F46
Controller
public function cart()
{
return view('frontend/cart');
}
public function addCart(Request $request)
{
$product = Product::findOrFail($request->id);
$cartItem = Cart::add([
'id' => $product->id,
'product_name' => $product->name,
'product_brand'=>$product->product_brand,
'qty' => $request->qty,
'product_price' => $product->product_price,
]);
Cart::associate($cartItem->rowId, 'App\Product');
return redirect()->route('cart.index');
}
}
model product
class product extends Model
{
protected $fillable =[ 'id', 'product_name', 'product_price',
'product_image',
'product_brand'];
}
html view
<tbody class="cart-table__body">
#foreach (Cart::content() as $item)
<tr class="cart-table__row">
<td class="cart-table__column cart-table__column--image">
<a href=""><img src="{{ asset($item->model->image) }}" alt="product">
</a>
</td>
<td class="cart-table__column cart-table__column--product">
{{$item->model->product_name}}
</td>
<td class="cart-table__column cart-table__column--price" data-title="Price">
{{$item->model->product_price}}</td>
<td class="cart-table__column cart-table__column--quantity" data-
title="Quantity">
<div class="input-number">
<input class="form-control input-number__input" type="number" min="1" value="
{{$item->qty}}">
<div class="input-number__add"></div>
<div class="input-number__sub"></div>
</div>
</td>
<td class="cart-table__column cart-table__column--total" data-title="Total">
</td>
<td class="cart-table__column cart-table__column--remove">
<a href="" class="btn btn-light btn-sm btn-svg-icon">
<svg width="12px" height="12px">
<use xlink:href="{{url('public/assets/images/sprite.svg#cross-12')}}"></use>
</svg>
</a>
</td>
</tr>
#endforeach
</tbody>
form html view
<form action="{{route('cart.action')}}" method="post"
class="product__options">
{{ csrf_field() }}
<input type="hidden" name="id" value="{{$single_products->id}}">
<input type="hidden" name="product_name" value="
{{$single_products->product_name}}">
<input type="hidden" name="product_image" value="
{{$single_products-
>product_image}}">
<input type="hidden" name="product_brand" value="
{{$single_products->product_brand}}">
<input type="hidden" name="product_price" value="
{{$single_products->product_price}}">
<div class="form-group product__option">
<label class="product__option-label" for="product-
quantity">Quantity</label>
<div class="product__actions">
<div class="product__actions-item">
<div class="input-number product__quantity">
<input id="product-quantity" name="qty" class="input-
number__input form-control
form-control-lg" type="number" min="1" value="1">
<div class="input-number__add"></div>
<div class="input-number__sub"></div>
</div>
</div>
<div class="product__actions-item product__actions-item--
addtocart">
<button class="btn btn-primary btn-lg">Add to
cart</button>
</div>
<div class="product__actions-item product__actions-item--
wishlist">
<button type="button" class="btn btn-secondary btn-svg-
icon btn-lg" data-
toggle="tooltip" title="Wishlist">
<svg width="16px" height="16px">
<use xlink:href="
{{url('public/assets/images/sprite.svg#wishlist-
16')}}"></use>
</svg>
</button>
</div>
<div class="product__actions-item product__actions-item--
compare">
<button type="button" class="btn btn-secondary btn-svg-
icon btn-lg" data-
toggle="tooltip" title="Compare">
<svg width="16px" height="16px">
<use xlink:href="
{{url('public/assets/images/sprite.svg#compare-16')}}">
</use>
</svg>
</button>
</div>
</div>
</div>
</form>
Route::get('/cart','CartController#cart')->name('cart.index');
Route::post('cart/action','CartController#addcart')-
name('cart.action');
Laravel introduced breaking changes around 5.8/6.0 wherein they removed a lot of the helper functions in favor of using the facades.
The problem is that this function:
arr_get()
which is the cause of the error, is unfortunately no longer part of the standard Laravel build. If it was in your own class, you could change this out to use the facade:
use Illuminate\Support\Arr;
and then in your method:
Arr::get();
Instead of changing the vendor code, you could check to see if you have the latest version of the shopping cart package, which would be compatable with Laravel's later versions... or you can add the helper package from Laravel that will bring back those helpers into your base Laravel distro.
How to display error on top of page instead of display errors beside input html element. Please suggest.
<ng-form name="frmdisbursementScheduleMaintenance">
<div style="padding-bottom: 8px;">
<button id="cm-SaveBtn" name="cm-SaveBtn" type="button" ng-click="submitted=true">Save</button>
<button id="cm-RefreshBtn" name="cm-RefreshBtn" type="button">Refresh</button>
</div>
<div>
<table>
<tr>
<td><span class="VNAVLabel">Process Begin Date: </span></td>
<td>
<span><input type="date" name="processBeginDate" ng-model="processBeginDate" required></span>
<span ng-show="(frmdisbursementScheduleMaintenance.processBeginDate.$dirty || submitted) && frmdisbursementScheduleMaintenance.processBeginDate.$error.required">
Process Begin Date is required
</span>
</td>
</tr>
</table>
</div>
</ng-form>
You have all the form's errors in form.$error.
Simply iterate on the errors and show wherever you want. Like:
<ul>
<li ng-repeat="(key, errors) in form.$error track by $index">{{ key }} errors :
<ul>
<li ng-repeat="error in errors">{{ error.$name }}-{{ key }}</li>
</ul>
</li>
</ul>
i am facing one issue due to one button control existed with same ID at two place in single page.
As i have created a custom field for jira which is appear on issue view screen and edit screen both.
"Edit" screen is just be a DIV and appear as display none till edit is clicked else issue view screen is appear (both on single page).
my created button existed on both the area.
How can we keep the condition like -
if parent is "DIV - edit" then keep different ID of button
ELSE
another ID of button. ? or any another way of jquery to resolve this conflict issue.
Below is stuff which shows same control at two place:
issue view screen stuff on a page:
.... .....
<li id="rowForcustomfield_11200" class="item">
<div class="wrap">
<strong title="final Dynamic Value" class="name">final Dynamic Value:</strong>
<div id="customfield_11200-val" class="value type-dynamicvalue editable-field active"
data-fieldtype="dynamicvalue">
<form id="customfield_11200-form" class="ajs-dirty-warning-exempt" action="#">
<div class="inline-edit-fields">
<div class="field-group">
<table id="customfield_11200:maintable">
<tbody>
<tr width="15%">
<tr width="15%">
<tr width="15%">
<tr width="15%">
<tr width="15%">
<tr width="15%">
<tr width="15%">
</tbody>
</table>
<input type="button" value="add" id="finaladd" />**PROBLEM CONTROL**
<input type="button" value="remove" id="finalremove" />**PROBLEM CONTROL**
</div>
</div>
<span class="overlay-icon throbber" />
<div class="save-options" tabindex="1">
</form>
</div>
</div>
</li>
......
....
..
note: i have highlighted above with tag comment as "PROBLEM CONTROL
Another stuff on same page for edit issue screen div:
.......
.............
<div id="edit-issue-dialog" class="aui-popup box-shadow aui-dialog-open popup-width-custom aui-dialog-content-ready"
style="width: 810px; margin-left: -405px; margin-top: -263.5px;">
<h2 class="aui-popup-heading">
<div class="aui-popup-content">
<div class="qf-container">
<div class="qf-unconfigurable-form">
<form action="#" name="jiraform" class="aui">
<div class="form-body" style="max-height: 419px;">
<input type="hidden" name="id" value="11100" />
<input type="hidden" name="atl_token" value="BP8Q-WXN6-SKX3-NB5M|6533762274aaa5d16f14dbbe010917f161596d8d|lin" />
<div class="content">
<div class="aui-tabs horizontal-tabs" id="horizontal">
<ul class="tabs-menu">
<div class="tabs-pane" id="tab-0">
<div class="tabs-pane active-pane" id="tab-1">
<div class="field-group aui-field-something">
<div class="field-group">
<div class="field-group">
<div class="field-group">
<label for="customfield_11200">
final Dynamic Value</label>
<table id="customfield_11200:maintable">
<input type="button" value="add" id="finaladd" /> **PROBLEM CONTROL**
<input type="button" value="remove" id="finalremove" /> **PROBLEM CONTROL**
</div>
</div>
</div>
<div class="field-group aui-field-wikiedit comment-input">
</div>
</div>
<div class="buttons-container form-footer">
</form>
</div>
</div>
</div>
</div>
.....
...
..
NOTE: above highlighted issue at PROBLEM CONTROL tag comment.
I think you can differentiate by using the id edit-issue-dialog
if($("#edit-issue-dialog").length){
//u r in edit form, and do your stuff
}else{
//in create form do your stuff
}
I am making 2 different web application for smart phones, using jQuery mobile and webapp-net.
so far I have the following codes: (its just a part of these codes, since I can not put the whole thing here)
<div data-role="collapsible" data-collapsed="true">
<h3>Eenmalige machtiging </h3>
<div data-role="fieldcontain" >
<form >
<input type="number" pattern="[0-9]*" id="anum" maxlength="9" placeholder="Account Number" autocomplete="off" onBlur="isValidAnum()" onFocus="emptyAnum('anum')"/>
<input type="text" id="bname" placeholder="Beneficiary Name" autocomplete="off" onBlur="isValidBname()" onFocus="emptyBname('bname')"/>
<table>
<tr><td>
Select Your Bank
</td>
<td>
<select name="select-bank" id="select-bank" class="select-bank" data-inline = "true" >
<option value="abn">ABN Amro</option>
<option value="rabo">Rabo Bank</option>
<option value="ing">ING Bank</option>
<option value="overige"> --Overig--</option>
</select>
</td>
</tr>
</table>
<table>
<tr>
<td>I Agree </td>
<td><input type="checkbox" class = "checkbox" name="cbox" id="cbox2"/></td>
</tr>
<tr>
<td> </td>
</tr>
</table>
<br/>
<a data-role = "button" type="submit" data-icon = "check" data-theme="b">Pay</a>
</form>
</div>
</div>
</div>
</div>
and:
<button class="form_header" id="last_method"><img src="appimages/directdebit_NL.png" align="middle" /> Eenmalige Machtiging</button>
<div class="form_body">
<fieldset>
<ul>
<li>
<input type="number" pattern="[0-9]*" id="anum" maxlength="9" placeholder="Account Number" autocomplete="off" onBlur="isValidAnum()" onFocus="emptyAnum('anum')"/>
</li>
<li>
<input type="text" id="bname" placeholder="Beneficiary Name" autocomplete="off" onBlur="isValidBname()" onFocus="emptyBname('bname')"/>
</li>
<li>
<table>
<tr><td>
Select Your Bank
</td>
<td>
<select name="select-bank" id="select-bank" class="select-bank" data-inline = "true" >
<option value="abn">ABN Amro</option>
<option value="rabo">Rabo Bank</option>
<option value="ing">ING Bank</option>
<option value="overige"> --Overig--</option>
</select>
</td>
</tr>
</table>
</li>
<li>
<table>
<tr>
<td>I Agree </td>
<td><input type="checkbox" class = "checkbox" name="cbox" id="cbox2" /></td>
</tr>
<tr>
<td> </td>
</tr>
</table>
<input type="submit" value="Pay" class="pay_button"/>
</li>
</ul>
</fieldset>
</div>
</div>
</div>
Now I have to create a .vm file using these two codes, in order to do that I need to see what are the difference in html between these two. I tried to make it look alike each other as much as I could, I dont think I can change them any more. I was also trying to work with their css but I didnt change anything.
my question is there a possible way to put these html in a single .vm file??? if you know how to do it please help me, also if you need more info just ask me.
Are you talking about file diff? Where you check the differences in two files and merge them?
There is winmerge http://winmerge.org/
There is examdiff. Do a google search for file comparison or file diff