0

I have this strange problem, I never had before and it only occurs in Google Chrome browser. I have made a function to create a writebutton (that writes a value to my PLC true ajax). This is how it looks:

    function makeWriteButton(id, address, value, startRefresher){

            $("#" + id).click( function() {
                writeData(address, value, startRefresher);
            });
    }

So you pass the id of your input button to that function and the function adds a click event handler, this function works perfect in IE, Firefox, Safari, Opera, but not in Chrome.

Does anyone have any suggestions or reasons why this doesn't work? and by the way this function used to work before on chrome but I don't know what I did so it's doesn't work anymore in chrome, really weird.

9
  • 3
    Is there anything in the console log in Chrome Developer Tools (F12)? Commented Apr 23, 2013 at 15:18
  • 1
    Test the output of your id via alert or console.log and see what you get! For example, inside the click event you can do alert(id); Commented Apr 23, 2013 at 15:19
  • How do you call makeWriteButton function, make sure your id is set Commented Apr 23, 2013 at 15:19
  • Did you wrap event with $(document).ready()? Commented Apr 23, 2013 at 15:25
  • @djthoms thx for the tip, when I add an alert, the alert is displayed but the value isn't written to my controller (the led doesn't go on) so i know now the problem lies somewhere else, but where because the same code seems to be working fine in IE, FF, etc. Commented Apr 23, 2013 at 15:43

1 Answer 1

1

I don't think your problem is in that section of code, this worked for me on Chromium

<button id="but1">Button1</button>
<button id="but2">Button2</button>
<button id="but3">Button3</button>
<button id="but4">Button4</button>
<button id="but5">Button5</button>

function makeWriteButton(id, address, value, startRefresher) {
    $("#" + id).click(function () {
        alert(address + " " + value + " " + startRefresher);
    });
}

makeWriteButton("but3", 5, 6, 7);

on jsfiddle

Sign up to request clarification or add additional context in comments.

1 Comment

yeah I found out that the code does function properly there must be some problem with my write function, I tested with an alert and i get the alert but the output led on my controller doesn't light up. but I didn't change anything to my write function and it used to work perfectly and it still does but not in chrome :s no problems or what so ever in firefox, safari, opera, ie

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.