POST
|
I run a block of code that runs off of lost focus. It runs fine the first time, but then I try to set focus to a textbox(which appears not to work) so I click in the textbox and tab out. The lost focus event does not work that time? Why is that? Here is the related code: on(document.getElementById('ownerAddress'), 'focusout', checkAddress);
on(document.getElementById('ownerAddress'), 'focusin', getElementId);
function getElementId() {
node = document.activeElement.id;
}
function checkAddress() {
console.log(node);
var locator = new Locator("http://maps.decaturil.gov/arcgis/rest/services/Public/WebAddressLocator/GeocodeServer");
//console.log(document.getElementById('ownerAddress').value);
//node = document.getElementById('ownerAddress');
node = document.getElementById(node);
// according to your service it takes Single Line
var params = {
"Single Line Input": node.value
};
locator.addressToLocations(params).then(function (addressCandidates) {
//console.log('success', addressCandidates);
//console.log(addressCandidates.length);
data = {
identifier: "id",
items: []
};
layout = [[
// {'name': 'FID', 'field': 'id', 'width': '50px'},//
{ 'name': 'Address', 'field': 'address', 'width': '200px' }
]];
if (addressCandidates.length > 1) {
for (a = 0; a < addressCandidates.length; a++) {
// This is the address that should go into a grid cell
data.items.push(lang.mixin({ id: a + 1 }, { address: addressCandidates.address }));
console.log(addressCandidates.address);
}
console.log(addressCandidates);
items = arrayUtils.map(addressCandidates, function (result) {
console.log(result);
return result;
});
console.log(items);
}
console.log("Log" + data);
if (window.grid) {
Maingds
dojo.destroy('grid');
dijit.byId('grid').destroy(true);
registry.remove(dom.byId('gridDiv'));
}
store = new ItemFileWriteStore({ data: data });
grid = new DataGrid({
id: 'grid',
store: store,
structure: layout,
autoWidth: true,
autoHeight: false,
rowSelector: '20px'
});
// display grid
//document.getElementById("grid").style.display = "block";
//alert("hello " + addressCandidates.length);
// Show modal
if (addressCandidates.length >= 1) {
$("#myModal").modal("show");
$('#myModal').show(function () {
$(this).trigger('isVisible');
});
//registry.byId("grid").display=block;
grid.on("rowclick", onRowClickHandler);
//console.log(addressCandidates.length);
//hookup the event
$('#myModal').bind('isVisible', isVisible);
var adresses = addressCandidates.map(function () {
return x.address;
});
//console.log(adresses);
}
else
{
alert("This address does not appear to be a city address. Please try again.");
document.getElementById(node).focus();
}
}).otherwise(function (err) {
console.log('somethings wrong', err);
});
}
//declare event to run when div is visible
function isVisible() {
/*append the new grid to the div*/
grid.placeAt("gridDiv");
/*Call startup() to render the grid*/
grid.startup();
}
function onRowClickHandler(evt) {
console.log(evt);
var clickedAddress = evt.grid.getItem(evt.rowIndex).address;
console.log(clickedAddress);
alert(clickedAddress);
// console.log(evt.explicitOriginalTarget.data);
}
});
... View more
08-18-2015
12:40 PM
|
0
|
1
|
2998
|
POST
|
I am not sure how I would apply it here, but that is an interesting feature.
... View more
08-18-2015
12:26 PM
|
0
|
1
|
679
|
POST
|
It looks like I needed to remove my return statement and then wrap document.getElementById around the global variable node. I decided to leave this up in case someone wants to use a value from another function for use in a current function. I needed to modify my code like follows: on(document.getElementById('ownerAddress'), 'focusout', checkAddress);
on(document.getElementById('ownerAddress'), 'focusin', getElementId);
function getElementId() {
// I am not sure why I can't access this value when I attempt to get the node.value
console.log(document.activeElement.id);
node = document.activeElement.id;
// return node;
}
function checkAddress() {
console.log(node);
var locator = new Locator("http://maps.decaturil.gov/arcgis/rest/services/Public/WebAddressLocator/GeocodeServer");
//console.log(document.getElementById('ownerAddress').value);
//node = document.getElementById('ownerAddress');
node = document.getElementById(node);
// according to your service it takes Single Line
var params = {
"Single Line Input": node.value
}; You were right Kelly Hutchins.
... View more
08-13-2015
02:39 PM
|
0
|
3
|
679
|
POST
|
I have the following block of code where I ewant to set the node value based on the focus event so that I can reuse this block of code. It works when I use this line: node = document.getElementById('ownerAddress'); but not when I try to set node to a variable. I also have node declared as a global variable. I thought I could access it since I returned the value in my getElementId function and then use the node.value in the checkAddress function, but there is no value at that time. What am I doing wrong in this block? on(document.getElementById('ownerAddress'), 'focusout', checkAddress);
on(document.getElementById('ownerAddress'), 'focusin', getElementId);
function getElementId() {
console.log(document.activeElement.id);
node = document.activeElement.id;
console.log(node);
return node;
}
function checkAddress() {
var locator = new Locator("http://maps.decaturil.gov/arcgis/rest/services/Public/WebAddressLocator/GeocodeServer");
//console.log(document.getElementById('ownerAddress').value);
//node = document.getElementById('ownerAddress');
// according to your service it takes Single Line
var params = {
"Single Line Input": node.value
};
... View more
08-12-2015
02:53 PM
|
0
|
4
|
3349
|
POST
|
I have seen the issue of needing to destroy items before due to conflicts. If you are interested I would be willing to help learn/create a Bootstrap template on Github to make a responsive app. Still learning responsive, but I am very much into learning new things and very active into helping out when I can and would welcome the challenge.
... View more
08-12-2015
02:29 PM
|
0
|
0
|
1390
|
POST
|
I would have to review mine or ask the person if it's okay if I use there photo. But I think they would find it interesting if possible. I was thinking along the lines of Bird's eye from Microsoft since those are at an angle, but it would be more ideal if there were an Esri tool.
... View more
08-12-2015
01:50 PM
|
0
|
0
|
596
|
POST
|
I had a statement like this as I referenced the ArcGIS API for JavaScript: on(document.getElementById('ownerAddress'), 'focusin', getElementId); which references the focusin event in jQuery, but I could not use onfocus event from JavaScript. Why is this?
... View more
08-12-2015
01:46 PM
|
0
|
0
|
2480
|
POST
|
I was hoping there might be a patter matching tool or something like that.
... View more
08-12-2015
01:39 PM
|
0
|
3
|
596
|
POST
|
I recently notice somebody posted a picture that they took from a plane that they were flying on, but did not know where they were taking a picture of. Are there any tools for matching of pictures with geography by maybe using the altitude of the plane if available, or even an estimate of the flight path?
... View more
08-12-2015
12:59 PM
|
0
|
6
|
3540
|
POST
|
It was a jQuery issue. I should have used: on(document.getElementById('ownerAddress'), 'focusin', getElementId);
... View more
08-12-2015
12:45 PM
|
0
|
0
|
313
|
POST
|
I am trying to get the element name in the onfocus event. I created a shorter block of code here: JS Bin - Collaborative JavaScript Debugging But I get the error: Uncaught TypeError: Cannot read property 'call' of undefinedk.parse @ init.js:208k @ init.js:208(anonymous function) @ onFocus.html:62ha @ init.js:22(anonymous function) @ init.js:23ia @ init.js:23fa @ init.js:23g @ init.js:25(anonymous function) @ init.js:30 And I have checked my code with Lint here: The Online Lint
... View more
08-12-2015
12:39 PM
|
0
|
1
|
2644
|
POST
|
Chris, Awesome! There was some duplication in the code, but it worked out great! Had no idea why it would show up. Thanks for adding the documentation as well. Here is my complete code for anyone that needs it: <!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="http://js.arcgis.com/3.14/dijit/themes/claro/claro.css">
<link rel="stylesheet" href="http://js.arcgis.com/3.14/esri/css/esri.css">
<script src="http://js.arcgis.com/3.14/"></script>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<style>
#gridDiv {
height: 100%;
width: 100%;
}
#myModal {
height: 100%;
width: 100%;
}
.modal-body {
height: 300px;
}
</style>
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7/html5shiv.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body class="claro">
<label id="lblOwnerAddress" for="ownerAddress">Owner's Address</label>
<input type="text" id="ownerAddress" name="ownerAddress" value="111 S Main" />
<div id="mainDiv" class="container">
<!-- Modal -->
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Modal Header</h4>
</div>
<div class="modal-body">
<div id="gridDiv"></div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
<script>
var items;
require([
"dojo/on",
"dojo/_base/array",
"esri/tasks/locator",
"dojox/grid/DataGrid",
"dojo/data/ItemFileWriteStore",
"dijit/registry", "dojo/parser",
"dijit/registry",
"dojo/dom",
"dojo/_base/lang",
"dijit/layout/ContentPane",
"dojo/domReady!"
],
function (on, arrayUtils, Locator, DataGrid, ItemFileWriteStore, registry, parser, registry, dom, lang) {
parser.parse();
var store, grid, data, layout;
//document.getElementById("grid").style.display = "none";
on(document.getElementById('ownerAddress'), 'focusout', checkAddress);
function checkAddress() {
var locator = new Locator("http://maps.decaturil.gov/arcgis/rest/services/Public/WebAddressLocator/GeocodeServer");
//console.log(document.getElementById('ownerAddress').value);
var node = document.getElementById('ownerAddress');
// according to your service it takes Single Line
var params = {
"Single Line Input": node.value
};
locator.addressToLocations(params).then(function (addressCandidates) {
//console.log('success', addressCandidates);
//console.log(addressCandidates.length);
data = {
identifier: "id",
items: []
};
layout = [[
// {'name': 'FID', 'field': 'id', 'width': '50px'},//
{ 'name': 'Address', 'field': 'address', 'width': '200px' }
]];
if (addressCandidates.length > 1) {
for (a = 0; a < addressCandidates.length; a++) {
// This is the address that should go into a grid cell
data.items.push(lang.mixin({ id: a + 1 }, { address: addressCandidates.address }));
console.log(addressCandidates.address);
}
console.log(addressCandidates);
items = arrayUtils.map(addressCandidates, function (result) {
console.log(result);
return result;
});
console.log(items);
}
console.log("Log" + data);
if (window.grid) {
dojo.destroy('grid');
dijit.byId('grid').destroy(true);
registry.remove(dom.byId('gridDiv'));
}
store = new ItemFileWriteStore({ data: data });
grid = new DataGrid({
id: 'grid',
store: store,
structure: layout,
autoWidth: true,
autoHeight: false,
rowSelector: '20px'
});
// display grid
//document.getElementById("grid").style.display = "block";
// Show modal
$("#myModal").modal("show");
$('#myModal').show(function () {
$(this).trigger('isVisible');
});
//registry.byId("grid").display=block;
grid.on("rowclick", onRowClickHandler);
//console.log(addressCandidates.length);
//hookup the event
$('#myModal').bind('isVisible', isVisible);
var adresses = addressCandidates.map(function () {
return x.address;
});
//console.log(adresses);
}).otherwise(function (err) {
console.log('somethings wrong', err);
});
}
//declare event to run when div is visible
function isVisible() {
/*append the new grid to the div*/
grid.placeAt("gridDiv");
/*Call startup() to render the grid*/
grid.startup();
}
function onRowClickHandler(evt) {
console.log(evt);
var clickedAddress = evt.grid.getItem(evt.rowIndex).address;
console.log(clickedAddress);
alert(clickedAddress);
// console.log(evt.explicitOriginalTarget.data);
}
});
</script>
</body>
</html>
... View more
08-01-2015
08:57 PM
|
0
|
2
|
1390
|
POST
|
Did it display addresses for you? There should be two addresses when you tab out of the textbox.
... View more
07-31-2015
02:54 PM
|
0
|
0
|
1390
|
POST
|
That works well. Thank you. Any idea how to get a grid to display in a bootstrap dialog box in my other question: https://community.esri.com/message/540491?et=watches.email.thread#540491
... View more
07-31-2015
01:54 PM
|
0
|
1
|
523
|
POST
|
I was asked to validate text boxes after users entered in addresses, otherwise this would be a lot simpler.
... View more
07-31-2015
01:36 PM
|
0
|
2
|
1390
|
Title | Kudos | Posted |
---|---|---|
1 | 06-24-2015 06:06 AM | |
1 | 07-15-2015 12:34 PM | |
1 | 02-26-2015 12:31 PM | |
1 | 05-21-2015 02:27 PM | |
1 | 07-13-2015 09:18 AM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|