PDA

View Full Version : how do you pass parameters?



Slapyo
30 Nov 2006, 1:44 PM
I would like to be able to call a function I made that accepts a parameter when I click the submit button I made for my dialog. But it doesn't get called and I get an error. If I remove the parameter from the string and I just put deleteString() nothing is passed to the function.


dlgEditString.addButton('Delete', deleteString(document.getElementById('editStringId').value), dlgEditString);

At the top of my file I have this:

<script type="text/javascript">
function deleteString(stringId) {
alert(stringId);
}
</script>

Animal
30 Nov 2006, 1:50 PM
You need to specify a function reference, not the results of an immediate function call.

To bind a set of parameters known at setup time to the function, use Function.createCallback.

To bind a scope, and possibly parameters, use Function.createDelegate.

All documented in the docs centre, and there are examples throughout the example code and the library.

Slapyo
30 Nov 2006, 2:15 PM
OK thanks.