Ok, I think I have one last outstanding problem with Giva Labs'
awesome Linkselect plug-in. I'm wondering if it is a limitation of the
plug-in or if I am simply doing something wrong.

I am using one select to update another and everything works
perfectly. However, I am finding the "change" function fires when I
use "replaceOptions" to update the second select even though I'm
simply re-initiating the second select with a new set of options. I
think the "change" function should only fire when I do I physically
select another option in the second select and not every time I update
the first select.

I've recreated a cut/paste demo to illustrate the point below. As you
can see, the alert occurs when changing either the first or second
select.


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">
<head>
  <title>Test</title>

        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/
libs/jquery/1.2.6/jquery.min.js"></script>
        <script type="text/javascript" src="http://www.givainc.com/labs/lib/
jquery.linkselect.js"></script>
        <script type="text/javascript" src="http://www.givainc.com/labs/lib/
jquery.bgiframe.js"></script>

        <link type="text/css" href="http://www.givainc.com/labs/css/
jquery.linkselect.css" rel="stylesheet" title="default" media="all" /
>
        <link type="text/css" href="http://www.givainc.com/labs/css/
jquery.linkselect.style.select.css" rel="alternate stylesheet"
title="select" media="all" />

  <script type="text/javascript">
    $(function(){

        $("#one").linkselect({
            change: function(){
                $("#two").linkselect("replaceOptions",
[{value:"1",text:"asdf"}, {value:"2",text:"qwer"}]);
            }
        });

        $("#two").linkselect({
            change: function(){
                alert('fired prematurely');
            }
        });

    });
  </script>

</head>
<body>
    <select id="one">
        <option>option 1-1</option>
        <option>option 1-2</option>
        <option>option 1-3</option>
    </select>
    <select id="two">
        <option>option 2-1</option>
        <option>option 2-2</option>
        <option>option 2-3</option>
    </select>


    </body>
</html>

Reply via email to