Extra Click Event

View: New views
4 Messages — Rating Filter:   Alert me  

Extra Click Event

by pczurak :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I have the following code and the problem I am having is after I select an item from the combo box which causes an OnChange event like it should but then if I click anywhere on the screen I get a second OnChange event from the combo box, how do I prevent this extra  OnChange event

Thank You

Peter


<!-- The Code -->

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>QueryReadStore Demo</title>
        <style type="text/css">
        @import "dojo-release-1.1.1/dijit/themes/tundra/tundra.css";
        @import "dojo-release-1.1.1/dojo/resources/dojo.css"
        </style>
       
        <script type="text/javascript" src="dojo-release-1.1.1/dojo/dojo.js" djConfig="isDebug: true, parseOnLoad: true"></script>
        <script type="text/javascript">
            dojo.require("dijit.form.ComboBox");
            dojo.require("dijit.form.FilteringSelect");
            dojo.require("dojox.data.QueryReadStore");

            dojo.provide("ComboBoxReadStore");
            dojo.declare(
                "ComboBoxReadStore",
                dojox.data.QueryReadStore,
                {
                    fetch:function(request) {
                        request.serverQuery = {q:request.query.name};
                        return this.inherited("fetch", arguments);
                    }
                }
            );
           
           
        function update_cbox_store() {
    // get the combobox widget with id my_combo_box
    cbox = dijit.byId('fs');
    // create new data store - update URL as needed
    new_store = new ComboBoxReadStore({url: 'States2.txt'});
    // assign new data store to combobox, should refresh with new
    // server data
    cbox.store = new_store;
    alert("cbox " + cbox);

        }


        dojo.addOnLoad( function () {
      dojo.connect(dojo.byId('foo'), 'onclick', update_cbox_store);
    }) ;

           
        function setVal2(val)
        {
                alert("val= " + val);
        }

        </script>
    </head>
    <body class="tundra">
        <div dojoType="ComboBoxReadStore" jsId="store"
             url="dojo-release-1.1.1/dojox/data/tests/stores/QueryReadStore.php"
             requestMethod="get"
             >
        </div>
        State: <input id="fs" dojoType="dijit.form.FilteringSelect" store="store" pageSize="15" OnChange="setVal2" style="width: 300px; font-size: 10pt;"/>
        <button id="foo" >Click Me!</button>
    </body>
</html>

Re: Extra Click Event

by vikas patil :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Peter,
            You could try these things:

1. Check if you are getting the exact button element just before you associate the connect event.
2. Check if the dojo.connect returns the right value(some array descrining your onchange event and its associated elements)
3. Try doing awindow.onload, bcz I have faced some similar problems with the dojo.onload() but it was long back.

Thanks and Regards,
Vikas A Patil  

On Fri, Jun 6, 2008 at 10:08 AM, pczurak <CZUPET@...> wrote:

I have the following code and the problem I am having is after I select an
item from the combo box which causes an OnChange event like it should but
then if I click anywhere on the screen I get a second OnChange event from
the combo box, how do I prevent this extra  OnChange event

Thank You

Peter


<!-- The Code -->

<html>
   <head>
       <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
       <title>QueryReadStore Demo</title>
       <style type="text/css">
               @import "dojo-release-1.1.1/dijit/themes/tundra/tundra.css";
               @import "dojo-release-1.1.1/dojo/resources/dojo.css"
       </style>

       <script type="text/javascript" src="dojo-release-1.1.1/dojo/dojo.js"
djConfig="isDebug: true, parseOnLoad: true"></script>
       <script type="text/javascript">
           dojo.require("dijit.form.ComboBox");
           dojo.require("dijit.form.FilteringSelect");
           dojo.require("dojox.data.QueryReadStore");

           dojo.provide("ComboBoxReadStore");
           dojo.declare(
               "ComboBoxReadStore",
               dojox.data.QueryReadStore,
               {
                   fetch:function(request) {
                       request.serverQuery = {q:request.query.name};
                       return this.inherited("fetch", arguments);
                   }
               }
           );


       function update_cbox_store() {
               // get the combobox widget with id my_combo_box
               cbox = dijit.byId('fs');
               // create new data store - update URL as needed
               new_store = new ComboBoxReadStore({url: 'States2.txt'});
               // assign new data store to combobox, should refresh with new
               // server data
               cbox.store = new_store;
               alert("cbox " + cbox);

       }


       dojo.addOnLoad( function () {
               dojo.connect(dojo.byId('foo'), 'onclick', update_cbox_store);
       }) ;


       function setVal2(val)
       {
               alert("val= " + val);
       }

       </script>
   </head>
   <body class="tundra">
       <div dojoType="ComboBoxReadStore" jsId="store"

url="dojo-release-1.1.1/dojox/data/tests/stores/QueryReadStore.php"
            requestMethod="get"
            >
       </div>
       State: <input id="fs" dojoType="dijit.form.FilteringSelect"
store="store" pageSize="15" OnChange="setVal2" style="width: 300px;
font-size: 10pt;"/>
       <button id="foo" >Click Me!</button>
   </body>
</html>

--
View this message in context: http://www.nabble.com/Extra-Click-Event-tp17684530p17684530.html
Sent from the Dojo mailing list archive at Nabble.com.

_______________________________________________
FAQ: http://dojotoolkit.org/support/faq
Book: http://dojotoolkit.org/docs/book
Forums: http://dojotoolkit.org/forum
Dojo-interest@...

http://turtle.dojotoolkit.org/mailman/listinfo/dojo-interest



_______________________________________________
FAQ: http://dojotoolkit.org/support/faq
Book: http://dojotoolkit.org/docs/book
Forums: http://dojotoolkit.org/forum
Dojo-interest@...
http://turtle.dojotoolkit.org/mailman/listinfo/dojo-interest

Re: Extra Click Event

by pczurak :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I am not sure what you mean.

1)
I am not sure what button you are referring to, if you referring to the 'foo' button than the connect event does not relate to this problem, because I can remove the connect statement and the 'foo' button and I am sill getting the extra click event.

2)
I don't know what you mean, I don't have any connect statements that connect the combo box (I am new to dojo so I am might not be understanding your statement)

3)
What to I have to do with window.onload ?

vikas patil wrote:
Hi Peter,
            You could try these things:

1. Check if you are getting the exact button element just before you
associate the connect event.
2. Check if the dojo.connect returns the right value(some array descrining
your onchange event and its associated elements)
3. Try doing awindow.onload, bcz I have faced some similar problems with the
dojo.onload() but it was long back.

Thanks and Regards,
Vikas A Patil

On Fri, Jun 6, 2008 at 10:08 AM, pczurak <CZUPET@wsinc.com> wrote:

>
> I have the following code and the problem I am having is after I select an
> item from the combo box which causes an OnChange event like it should but
> then if I click anywhere on the screen I get a second OnChange event from
> the combo box, how do I prevent this extra  OnChange event
>
> Thank You
>
> Peter
>
>
> <!-- The Code -->
>
> <html>
>    <head>
>        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
>        <title>QueryReadStore Demo</title>
>        <style type="text/css">
>                @import "dojo-release-1.1.1/dijit/themes/tundra/tundra.css";
>                @import "dojo-release-1.1.1/dojo/resources/dojo.css"
>        </style>
>
>        <script type="text/javascript" src="dojo-release-1.1.1/dojo/dojo.js"
> djConfig="isDebug: true, parseOnLoad: true"></script>
>        <script type="text/javascript">
>            dojo.require("dijit.form.ComboBox");
>            dojo.require("dijit.form.FilteringSelect");
>            dojo.require("dojox.data.QueryReadStore");
>
>            dojo.provide("ComboBoxReadStore");
>            dojo.declare(
>                "ComboBoxReadStore",
>                dojox.data.QueryReadStore,
>                {
>                    fetch:function(request) {
>                        request.serverQuery = {q:request.query.name};
>                        return this.inherited("fetch", arguments);
>                    }
>                }
>            );
>
>
>        function update_cbox_store() {
>                // get the combobox widget with id my_combo_box
>                cbox = dijit.byId('fs');
>                // create new data store - update URL as needed
>                new_store = new ComboBoxReadStore({url: 'States2.txt'});
>                // assign new data store to combobox, should refresh with
> new
>                // server data
>                cbox.store = new_store;
>                alert("cbox " + cbox);
>
>        }
>
>
>        dojo.addOnLoad( function () {
>                dojo.connect(dojo.byId('foo'), 'onclick',
> update_cbox_store);
>        }) ;
>
>
>        function setVal2(val)
>        {
>                alert("val= " + val);
>        }
>
>        </script>
>    </head>
>    <body class="tundra">
>        <div dojoType="ComboBoxReadStore" jsId="store"
>
> url="dojo-release-1.1.1/dojox/data/tests/stores/QueryReadStore.php"
>             requestMethod="get"
>             >
>        </div>
>        State: <input id="fs" dojoType="dijit.form.FilteringSelect"
> store="store" pageSize="15" OnChange="setVal2" style="width: 300px;
> font-size: 10pt;"/>
>        <button id="foo" >Click Me!</button>
>    </body>
> </html>
>
> --
> View this message in context:
> http://www.nabble.com/Extra-Click-Event-tp17684530p17684530.html
> Sent from the Dojo mailing list archive at Nabble.com.
>
> _______________________________________________
> FAQ: http://dojotoolkit.org/support/faq
> Book: http://dojotoolkit.org/docs/book
> Forums: http://dojotoolkit.org/forum
> Dojo-interest@dojotoolkit.org<http://dojotoolkit.org/forumDojo-interest@dojotoolkit.org>
> http://turtle.dojotoolkit.org/mailman/listinfo/dojo-interest
>

_______________________________________________
FAQ: http://dojotoolkit.org/support/faq
Book: http://dojotoolkit.org/docs/book
Forums: http://dojotoolkit.org/forum
Dojo-interest@dojotoolkit.org
http://turtle.dojotoolkit.org/mailman/listinfo/dojo-interest

Re: Extra Click Event

by pczurak :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I've removed all of the unnecessary code so it will be easier to debug, but I am not sure where to look.  
I am still getting the second click event after I select any dropdown Item except the first one.

Can anyone help me?  I am very new to dojo so I am not sure where to start.


Thank You


To reproduce the problem:
Select any item from the dropdown box except the first one then click anywhere in the Window.


<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>QueryReadStore Demo</title>
        <style type="text/css">
        @import "dojo-release-1.1.1/dijit/themes/tundra/tundra.css";
        @import "dojo-release-1.1.1/dojo/resources/dojo.css"
        </style>
       
        <script type="text/javascript" src="dojo-release-1.1.1/dojo/dojo.js" djConfig="isDebug: true, parseOnLoad: true"></script>
        <script type="text/javascript">
            dojo.require("dijit.form.FilteringSelect");
            dojo.require("dojox.data.QueryReadStore");

            dojo.provide("ComboBoxReadStore");
            dojo.declare(
                "ComboBoxReadStore",
                dojox.data.QueryReadStore,
                {
                }
            );
           
        function setVal2(val)
        {
                console.debug("Selected "+val);
                alert("val= " + val);
        }

        </script>
    </head>
    <body class="tundra">
        <div dojoType="ComboBoxReadStore" jsId="store"
             url="dojo-release-1.1.1/dojox/data/tests/stores/QueryReadStore.php"
             requestMethod="put"
             >
        </div>
        State: <input id="fs" dojoType="dijit.form.FilteringSelect" store="store" pageSize="15" OnChange="setVal2" style="width: 300px; font-size: 10pt;"/>
    </body>
</html>