I'm very new to jquery / javascript. I have noticed that Function A that adds an item will work, but Function B stops working after Function A is called. I can get around this by re-including Function B in Function A but I find that to be inelegant. Surely, there is another way? I have already tried adding $document.ready(), but since this is included in that I'm guessing it's simply looping?
This is what I have so far:
<script type="text/javascript" charset="utf-8">
$(document).ready( function () {
//Function A
$('a#create').click( function() {
$("#existing").append('<option value="'+portName+'">'+portName+'</option>').multiselect("refresh");
//multiselect is a plug-in that makes select option tags nicer to look at, on refresh the html is correctly parsed for Function B to continue working, however it does not work unless I re-call Function B here. Again calling $document.ready() here doesn't work either.
});
// Function B
$('a.view').click( function() {
alert();
});
});
</script>
I understand that Function B is calling on an anchor link, however Function A properly creates these conditions for Function B to work. On a normal document load this is not a problem. However after calling Function A, Function B THEN breaks unless I include Function B in Function A.
Should I be looking into creating a function that calls all other functions to "refresh" them? I'm not even sure what the problem is as of yet. I stumbled upon this "fix".