We have a situation in which our forms are dynamically generated. This means that at the point where we are injecting an Address field we don't know if there are more addresses that may appear later on the form.

With that in mind, how can we push additional addresses onto the list?

We've tried running the QadApi function multiple times (once for each address that appears); however, the first one is the only one that executes.

I even tried accessing the QadServer object directly in order to "push" a new address to the array. However, that hasn't worked either.

Unfortunately, making these forms aware of the other fields that appear on them is simply not feasible right now...

UPDATE:
I tried it by having the additional addresses create a new QadServer object and pass in the relevant settings. However, this ONLY works if the autoClean parameter is set to true...

Considering I don't want it to validate until the form is submitted, I'm in a kind of catch 22.

As it stands, if I leave autoClean True then it validates the address on page load and again on submit... Which doubles the number of API calls I need to make. If I turn off autoClean, then the additional addresses don't validate at all.

asked 04 Feb, 23:02

School%20Office%20Pro's gravatar image

School Office Pro
367
accept rate: 0%

edited 05 Feb, 23:42


Kudos for getting as far as you did. Your use case is actually somewhat unique and not what the javascript implementation was designed to handle. The QadApi registration is meant to be executed when the page loads and wasn't really designed to accept additional addresses at a later point in the experience.

For your case, I recommend calling the REST endpoint using JSONP and rolling your own user interface. You would have to put in more work for the UI but the headache you would get from trying to hack the current javascript implementation is probably not worth it in the end (but you're more than welcome to download the javascript code and hack away if you'd like).

The idea is to register some of your own custom javascript to run on each new address form that calls the REST endpoint and presents the results to the user in some way (maybe like the popup we're using for the Javascription implentation). You would need to handle cases where there are not valid suggestions, just one valid suggestion and/or multiple valid suggestions. We also recommend allowing for the customer to override any suggestions with their original input, in case of new developments and USPS data inconsistencies.

We have a REST/JSONP sample using jQuery on github if you're interested.

link

answered 06 Feb, 11:45

Mike%20-%20SmartyStreets's gravatar image

Mike - SmartyStreets
10.4k3
accept rate: 56%

edited 03 Apr, 15:37

Jeffrey%20-%20SmartyStreets's gravatar image

Jeffrey - SmartyStreets ♦♦
2.2k14

FYI, I've just posted a new sample on the sample code repository on github. It uses a jQuery UI dialog and jQuery templates to display address suggestions from the REST API. It's pretty simplistic but it shows a few possibilities.

https://github.com/smartystreets/LiveAddressSamples/blob/master/jQuery/ui.html

(15 Feb, 11:36) Mike - SmartyStreets

We're looking at the sample now. I like the theme better than the standard one. Thanks.

(22 Feb, 15:10) School Office Pro
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×47
×23
×11

Asked: 04 Feb, 23:02

Seen: 188 times

Last updated: 03 Apr, 15:37