AnsweredAssumed Answered

Custom widget json returned via ajax

Question asked by qiqbal on Aug 10, 2015
Latest reply on Aug 11, 2015 by qiqbal

I would appreciate if anyone can help me in moving forward.

I have customized a simple CustomWidgetTemplate widget. In the widget.js I am extending the BaseWidget class by adding a function

_getData: function() {

  This function reads the contents in a input box, and sends a ajax request to a php file to search data in a SQL Server table based on string got from input box.

The data is retrieved as JSON

After parsing JSON, I am getting matching name and coordinates of the features based on the search string passed from input box.

var name

var coordinates

I am showing all the returned results as <ul> list li.innerHTML. I am creating the list as follows:

I have created a resultDiv in Widget.html

<div id="resultsDiv"></div>

dojo.place(ul,"resultsDiv");

var li = dojo.doc.createElement("li");

li.innerHTML = "<span data-dojo-attach-point='anattachpoint' data-dojo-attach-event='click: _onClick'>"+name+"</span>";

 

Upto this place everything is working fine. I can see the list, but when I click on the names, it does not seem to go to the _onClick function. I even created a simple alert("test") or console.log("Test") inside the _onClick function.

I am not succeeding in this.

Any help will be appreciated.

 

Thanks

Qazi Iqbal

Outcomes