Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need help: creating a link in a popup that executes method in widget #209

Closed
jebu75 opened this issue Sep 15, 2014 · 5 comments
Closed

Need help: creating a link in a popup that executes method in widget #209

jebu75 opened this issue Sep 15, 2014 · 5 comments

Comments

@jebu75
Copy link
Collaborator

jebu75 commented Sep 15, 2014

I working on a widget that searches our plant (trees, shrubs) etc. database. It adds it's own feature layer to the map to display the results. The feature layer has a infoTemplate configured that lists attributes for each feature and contains a number of links to Google Image searches passing various attributes (genus, species, plant name etc) as the search term.

I would like to be able to add another link in the infoTemplate that calls a method defined in my widget on click. The method would search the database for similar plants based on attributes of the plant displaying the infoTemplate.

Here's how I am building the infoTemplate:
https://gist.github.com/jebu75/4cc678ebc2ff9e5bcd4c

Is it as simple as this?

<a href="javascript.html" onclick="myWidgetMethod">Some link</a>

Doesn't seem so...

Thanks for any help!

@friendde
Copy link
Contributor

Have you seen this sample?
https://developers.arcgis.com/javascript/jssamples/widget_extendInfowindow.html

I am working on adding a email link to the popup, where the email will change based on the indentify.js configuration. See my gist https://gist.github.com/friendde/2ce1841d3956fd29d82f which is incomplete and not working but shows my intent.

@friendde
Copy link
Contributor

In your gist your comment asks if there is a selction change event, which there is https://developers.arcgis.com/javascript/jsapi/popup-amd.html#event-selection-change

@jebu75
Copy link
Collaborator Author

jebu75 commented Sep 15, 2014

Thanks @friendde! I have seen that example before, maybe need to review in more detail. What I'm trying to figure out is how to call a method defined in my widget when the link is clicked. With the way contexts work in JS I'm not sure how to accomplish this.

Maybe something like this:

<a href="fakelink.htm" onclick="lang.hitch( this, this.myWidgetMethod )">Some link</a>

I'll take a look at your gist and see if that helps.

@friendde
Copy link
Contributor

Rather than use the link click event why not use the popup's selection change event to compile your google search url. So when the selection change event occurs you call your method to compile the terms and the link appears on the popup.

@jebu75
Copy link
Collaborator Author

jebu75 commented Sep 15, 2014

Sorry @friendde. I think I may have confused the issue by including the google search links. I meant those merely as examples and they work fine.

It's the additional link I would like to add which needs to call a method in my widget I'm not sure how to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants