I am using jquery template for my project. The problem I am facing is that when rendering a template I am converting $data to string and passing it in onclick function [see the code below].
<script id="Item" type="text/x-jquery-tmpl">
<li id="${ID}" class="card red ui-state-default">
<a class="desc" href="" onclick="return $$.popup.eItem('${($data)}');"> ${$data.Desc} </a>
</li>
</script>
the converting of $data object to string and passing it to a function
onclick="return $$.popup.eItem('${($data)}');"
here, $data is an object containing the actual data. And when I click the link I get the passed string as "[object Object]" and I want to convert it again back to jquery object so I can use it in my code.
I can use 'JSON.stringify()' to convert the $data object to JSON, like this
onclick="return $$.popup.editCard('${JSON.stringify($data)}');"
but as the template is rendered to html, this is the output:
<a class="desc" href="" onclick="return $$.popup.eItem('{"TemplateName":"CardItem","ID":"lc822","Desc":"make card EntityAssignId = 0","CardId":822,"LaneId":665,"Priority":1,"AssignedEntityId":0,"Pic":null,"SortOrder":2}');">make card EntityAssignId = 0</a>
So any suggestion?
Well if you want to access the properties of the data object maybe you should access them:
onclick="return $$.popup.eItem('${($data.ID)}');"
In this way you will get the ID property. You get "[object Object]" because that's the way that javascript uses to convert an object tio a string (you would get the same if you called alert($data);
From your expample I would expect my code to be converted to
<a class="desc" href="" onclick="return $$.popup.eItem('lc822');">make card EntityAssignId = 0</a>
because from your "Stringified" code i can see that the property ID of $data is equal to lc822
This is what you want:
console.log($('<div>').append( $data ).remove().html());
Hope this helps.
Related
How to check the empty list on Sightly?
I wanted to prevent render the item-list DIV if there was no item on itemImgaeList. But it returns me one (1) always if there were no items while trying with -
LIST_SIZE_PRINT = "${container.itemImgaeList.size}"; // retrun 1
HTL:
<div data-sly-test="${container.itemImgaeList.size > 1}">
<sly data-sly-list.imageList="${container.itemImgaeList}">
<div class="item-list">
<picture>
<img alt="${imageList.qlImageText}" src="${imageList.qlImagePath}" />
</picture>
</div>
</sly>
</div>
Any help?
data-sly-list can be used for implementing the above requirement of rendering the list elements only when the list is not empty.
The use of 'data-sly-test' is not required for checking a list, as the check for emptiness is done inherently by data-sly-list.
Here is a working example using data-sly-list:
<div class="item-list" data-sly-list.item="${container.itemImgaeList}">
<picture>
<img alt="${item.qlImageText}" src="${item.qlImagePath}" />
</picture>
</div>
More information:
https://www.aemquickstart.in/2016/08/htl-sightly-notes.html
<template>
<div class="container-wrapper">
<div if:false={loggedIn} class="slds-m-around_medium">
<span>Login to Salesforce App</span>
<lightning-input name='username' label="Username"></lightning-input>
<lightning-input type="password" name='password' label="Password"></lightning-input>
<br/>
<lightning-button variant="brand" label="Login" title="Login" onclick={login}></lightning-button>
</div>
</div>
</template>
login() {
console.log('login attempt');
console.log(this.template);
var Username =this.template.querySelector('input[name="username"]').value;
var Password =this.template.querySelector('input[name="password"]').value;
console.log(Password);
console.log(Username );
}
values are not getting fetch in username, password variables.
this.template.querySelector('input[name="username"]').value is not working.
I have also tried onchange event approach on lightning-input elements , in that case event.target was undefined ? I am stuck not able to read user input.
app screenshot
There is no property 'name' on lightning-input like on standard HTML input. You should use 'data-id' instead.
HTML:
<lightning-input data-id='username' label="Username"></lightning-input>
JS:
let username = this.template.querySelector('lightning-input[data-id=username]');
The <template> element is not a common element. It holds its (inactive) DOM content inside a Document Fragment that you can access through the content property.
Therefore you should try:
var Username = this.template.content.querySelector('input[name="username"]').value;
var Password = this.template.content.querySelector('input[name="password"]').value;
In Salesforce when you are accessing a lightning input using the query selector first you have to search for lightning-input tag not the input tag.
Secondly when you add a name attribute to the lightning-input that attribute is transfered to the input tag which is created when the lightning component is rendered. But you can not access the input tag (my assumption is that it's in the Shadow DOM). Therefore to search for the lighting-input you must use a class name to identify the lightning component.
<lightning-input type="number" class="optionEditQuantityVal" value={Quantity} variant="label-hidden" step="1" max-length="1"></lightning-input>
let input = this.template.querySelectorAll('lightning-input.optionEditQuantityVal')
I am very new to using OpenLayers and new to mapping. I am trying to create a simple map that is getting data from a postgresSQL. The data is then returned into a textarea (Linestring ........). I want to use the result to draw a line on the map.
So far I didn't have any luck making this happen. I can see the returned data from the database using console log.
Any working example/how to using WKT(linestring) OpenLayers 3 will be appreciated.
My HTML
<div class="map" id="map"></div>
<form action="#">
<div class="mdl-textfield mdl-js-textfield">
<textarea class="mdl-textfield__input" id="resultTxtArea" readonly rows="30"
type="text"></textarea> <label class="mdl-textfield__label" for=
"resultTxtArea">Text lines...</label>
</div>
</form>
Use the readFeature method from ol.format.WKT object (Documentation):
// some example linestring as WKT
var linestringWKT = 'LINESTRING(4 6,7 10)';
// get the feature
var feature = new ol.format.WKT().readFeature(linestringWKT);
After the app menu html is retrieved, it is displayed as text instead of html. Chrome complains Resource interpreted as Script but transferred with MIME type text/plain. I'm using MVC on the Force.com platform. I've tried specifying the content type of the response as "text/html" and "application/javascript", but neither worked.
[EDIT 1]
Code
<script>
intuit.ipp.anywhere.setup({
menuProxy: "https://c.na55.visual.force.com/"
+ "apex/bluedot",
grantUrl: "https://c.na55.visual.force.com/"
+ "apex/authpage"
});
</script>
<ipp:bluedot>
<div id="intuitPlatformAppMenu">
<a id="intuitPlatformAppMenuLogo" href="javascript:void(0);" title="Intuit App Center">
<span id="intuitPlatformAppMenuDot"> </span>
</a>
<div id="intuitPlatformAppMenuDropdown" style="display: none;">
<div id="intuitPlatformAppMenuDropdownTop"></div>
<div id="intuitPlatformAppMenuDropdownInner">
<<=======
</div>
</div>
</div>
</ipp:bluedot>
When dropdown is open, code is added at arrow location as string and a class 'open' is addedto #intuitPlatformAppMenuLogo.
Image
[EDIT 2]
Server side apex code
public with sharing class GetBlueDotMenu {
public String response {get; set;}
public GetBlueDotMenu() {
QbApiController api = new QbApiController ('GET', 'QB API' , null, null, 'https://appcenter.intuit.com/api/v1/Account/AppMenu');
response = api.execute();
}
}
api.execute() returns the response body and saves it to response which is then rendered on the page.
This issue arises from Visualforce's default rendering of strings as escaped. To fix it, the apex:outputText attribute escaped needs to be "false". See http://bit.ly/13CSXve
PFB link -
https://developer.intuit.com/docs/0025_quickbooksapi/0060_auth_auth/widgets/blue_dot_menu
For IE8, you should add (as mentioned in the above doc)
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ipp="">
You can clear the browser's cache and try it again.
Plz let me know how it goes.
Thanks
I want to update the value from a input/textfield with a calculated value from the cookie.It's like a mini local cookie cart.
Saving and retrieving the json from the cookie is a piece of cake.
In my behavior I fail to make the following work:
I added a class for every node in the input field, it's constructed like the example below.
Myid = 'webform_cart_nid_10';
formElement = $('.' + Myid);
console.log(formElement);
The html is quite nested and can be seen http://it2servu.be/broodjes/bestellen (if I may link?) .
the field whose value I want to update looks like this:
<input class="webform_cart_nid_10 webform_cart_nid form-text" type="text" id="edit-submitted-cart-item-cart-elements-10" name="submitted[cart_item][cart_elements][10]" value="0" size="3" maxlength="128">
Is contained in drupal output with severe div-itis.
<div class="page clearfix" id="page">
<div id="section-content" class="section section-content">
<div id="zone-content-wrapper" class="zone-wrapper zone-content-wrapper clearfix">
<div id="zone-content" class="zone zone-content clearfix container-12">
<div class="grid-12 region region-content" id="region-content">
<div class="region-inner region-content-inner">
<div class="block-inner clearfix">
<div class="content clearfix">
<div class="node node-webform node-promoted view-mode-full clearfix ">
<div class="field field-name-title field-type-ds field-label-hidden">
<form class="webform-client-form" enctype="multipart/form-data" action="/broodjes/bestellen" method="post" id="webform-client-form-5" accept-charset="UTF-8">
<div>
<fieldset class="collapsible form-wrapper collapse-processed" id="edit-submitted-cart-item-cart-elements">
<div class="fieldset-wrapper">
<div class="form-item form-type-textfield form-item-submitted-cart-item-cart-elements-10">
<input class="webform_cart_nid_10 webform_cart_nid form-text" type="text" id="edit-submitted-cart-item-cart-elements-10" name="submitted[cart_item][cart_elements][10]" value="0" size="3" maxlength="128">
...
probably it's something stupid, I just can't figure out what it is?
Your problem is with jQuery. If you pop open the console in Chrome and type jQuery, it returns the jQuery function. If you type $ it returns undefined. You have some sort of collision causing $ not to be set to jQuery.
use "jQuery" instead of "$"
Myid = 'webform_cart_nid_10';
formElement = jQuery('.' + Myid);
console.log(formElement);
the "$" never worked for me in Drupal 7.