In my Rails application, I have implemented the following code in an Ajax call:
<script type="text/javascript">
$(document).on('click','#share_button', function(e){
e.preventDefault();
FB.ui({
method: 'feed',
name: '<%= fb_data[:name] %>',
link: '<%= fb_data[:link]%>',
picture: '<%= fb_data[:picture] %>',
caption: '<%= fb_data[:caption] %>',
description: '<%= fb_data[:description] %>'
}
);
});
</script>
While this code functions properly in html views, it encounters issues when used in a view rendered through ajax. I suspect that the problem lies in the timing of the $(document) and ajax rendering, but I lack expertise in javascript and ajax to troubleshoot this. Can someone provide assistance?