I need to know how to add an event to a button. The specific issue is that I want to add an event which is a prototype function of a class. Consider the following as an example:
Look at the line: $('#test-btn').click(this.showFullName);
When the button is clicked, the event will actually get triggered, but there is a scope problem because the showFullName() function will produce the following error:
"this.getFirstName is not a function" on this line: alert(this.getFirstName() + ' ' + this.getLastName()); Is there any way to get around this problem or am I forced to use inline functions as event handlers?
Hi guys, this question is more related to Javascript than to jQuery but I'm hoping one of you guys can point me in the right direction.
I'm trying to write a generic javascript function which will populate a secondary SELECT list based on an option selected in a primary SELECT list. The data for the secondary list is retrieved via an ajax getJSON call. This is how the function looks like this:
function loadSecListFromPrimList(primListID, secListID, urlKeyID, loadingText, nonAvailText, ajaxURL) {
Notes: While the data is being loaded via ajax the secondary list text changes to something like: "busy loading...". Once the data is loaded it will clear and repopulate the secondary list.
The urlKeyID variable is passed through as a parameter of the loadSecondaryListFromList() function and needs to be dynamic so I can use the function all over my website. So I finally get to my question:
How do I use a value that was passed through a parameter of a function as a key in a dictionary? In this case I'm trying to set 'cid' as the key name (as per my HTML). I know it is a stupid question but I am baffled. I hope my explanation is detailed enough.