I’m just coming up to speed on jQuery, I’ll apologize up front if this is a rookie error.
I’m attempting to get a simple custom trigger to fire without and success. Maybe someone can help help out and show me why this isn’t working.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>jQuery Trigger example</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
$('#asset1').bind("triggerAssets", function() {
alert('Assets');
});
</script>
<script>
$(document).ready(function(){
$('#asset1').trigger("triggerAssets");
});
</script>
</head>
<body >
<div id="asset1" class="assets" >Asset
<table>
<tr>
<td>Field One: </td>
<td><input type="text" name="fieldOne" id="exfieldOne" value=""/></td>
</tr>
<tr>
<td>Field Two: </td>
<td><input type="text" name="fieldTwo" id="exfieldTwo" value=""/></td>
</tr>
<tr>
<td>Field Three: </td>
<td><input type="text" name="fieldThree" id="exfieldThree" value=""/></td>
</tr>
</table>
</div>
<hr>
</body>
</html>
Your binding function will run before the page is rendered;
#asset1doesn’t yet exist. Move it into thereadyhandler, which fires after the DOM is ready (and your element is present).