Tuesday, 25 July 2017

Facebook Share

<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({appId: '782543028437100', status: true, cookie: true,
xfbml: true});
};
(function() {
var e = document.createElement('
script'); e.async = true;
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
</script>


<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js" type="text/javascript"></script>



<h1>Listing products</h1>

<table>
  <tr>
    <th>Name</th>
    <th>Description</th>
    <th></th>
    <th></th>
    <th></th>
  </tr>

<% @products.each do |product| %>
  <tr>
 
    <td><%= product.name %></td>
    <td><%= product.description %></td>
    <%#= social_share_button_tag(product.name, :url => "http://localhost:3000/products/#{product.name}") %>
    <td><%= link_to 'Show', product %></td>
    <td><%= link_to 'Edit', edit_product_path(product) %></td>
    <td><%= link_to 'Destroy', product, confirm: 'Are you sure?', method: :delete %></td>
  </tr>

  <a href="shareere" id = "share_button">shhhhh</a>

<script type="text/javascript">
$(document).ready(function(){
$('#share_button').click(function(e){
e.preventDefault();
FB.ui(
{
method: 'feed',
name: '<%=product.name%>',
link: ' http://localhost:3000',
picture: 'http://www.hyperarts.com/external-xfbml/share-image.gif',

description: 'This is the content of the "description" field, below the caption.',
message: ''
});
});
});
</script>
<% end %>
</table>

<br />

<%= link_to 'New Product', new_product_path %>

<style type=”text/css”> img#share_button {cursor: pointer;} </style>


No comments:

Post a Comment