views:

51

answers:

2

Hi, at this page new customer, there is some clash between the two scripts. I have been asked to make the content shown when clicking the "ny kunde" button.

This script works fine now, thanks to Voyta.

There is another script made by another person that finds Company CEO information and inputs the data into the fields.

When I put the show script into the page, this function sottped working, as did the show hide on the checkbox lower down in the page.

How can I find out what's clashing? What am I looking for? Should I just give up?

Here is an example of the code I got working (I'm a jQuery noob).

Code on my .tpl

  <button id="button1">&nbsp;</button>

    {literal}

   <script src="http://code.jquery.com/jquery-latest.js"&gt;&lt;/script&gt;
         <script type="text/javascript">
$(function() {
    $("#button1").click(function() {
      $(".newCustomer").toggle("slow");
    });
});​
</script>

<div class="newCustomer">...

Thanks.

+1  A: 

You have syntax error click(function()1

It should be:

$(function() {
    $("#button1").click(function() {
      $(".newCustomer").toggle("slow");
    });
});​
Voyta
is there a `toggle('show')` ? i think it has to be `toggle('slow')`
meo
Thanks, I fixed that And seems to be working! But the org number getter isn't working now..
Kyle Sevenoaks
A: 

Make your life easier : since you are already using jQuery, you might as well use jQuery UI's nice dialog widget. It includes all the small things that are difficult to think of beforehand when you implement the whole thing by yourself :

  • make the dialog modal in order to prevent interactions with the rest of the page while the dialog is open
  • movable and resizable
  • the "plugs" (callback functions) to define what to do when user clicks OK, cancel, or just closes the dialog...

See : http://jqueryui.com/demos/dialog/#modal-form - try the modal form example

Pierre Henry
Thanks, I'll use this in the future, but for now I don't want to have to use a whole new thing when all I need is these two functions to work on the same page.
Kyle Sevenoaks