0
votes

My widget makes the form but the event that is suposed to happen doesn't. When the button is clicked it is supposed to grab the value in the input box then put it into URL that is being requested then paste that page into the results div.

EDIT NOTE: Found out that if I have the searchNode WITHOUT the dijit Button type the event works but if I apply the dojo-data-type it doesn't.

Widget:

/**
 * Widget for creating a quick search form.
 */
define([
    "dojo/_base/declare",
    "dojo/request",
    "dijit/_WidgetBase",
    "dijit/_OnDijitClickMixin",
    "dijit/_TemplatedMixin",
    "dijit/_WidgetsInTemplateMixin",
    "dijit/form/Button",
    "dijit/form/TextBox",
    "dojo/text!./templates/quickSearch.html"
],function(declare, request, _WidgetBase, _OnDijitClickMixin, _TemplatedMixin, _WidgetsInTemplateMixin, Button, TextBox, template){
    return declare("js/widget/SASearch", [_WidgetBase, _OnDijitClickMixin, _TemplatedMixin, _WidgetsInTemplateMixin], {
        //  set our template
        templateString: template,

        //  some properties
        baseClass: "searchWidget",

        //  define an onClick handler
        _onClick: function() {
            var query = this.queryNode.value;
            alert(query);
            request("quick/" + query).then(
              function(text) {
                  this.resultsNode.innerHTML = text;
                  alert(text);
              },
              function(error) {}
            );
        }
    });
});

Template:

<div class="${baseClass}">
    <div class="${baseClass}Query" data-dojo-attach-point="queryNode" data-dojo-type="dijit/form/TextBox"></div> 
    <div class="${baseClass}Search" data-dojo-attach-point="searchNode" data-dojo-type="dijit/form/Button" data-dojo-attach-event="ondijitclick:_onClick">Search</div><br />
    <div class="${baseClass}Results" data-dojo-attach-point="resultsNode"></div>
</div>
1

1 Answers

0
votes

Your event has to be

data-dojo-attach-event="onClick:_onClick"

On the button.

Also for the returns on the request, your going to have to use dojo.hitch to hitch this. http://jsfiddle.net/theinnkeeper/qum452gm/