I don't know how the fb script works. The point is that if it works on an 
element that is present on the page AFTER being LOAD()ed, at the time you 
run the script on the "container" the LOAD()ed piece is likely not to be 
there already. 

On Wednesday, February 18, 2015 at 11:26:08 AM UTC+1, Gael Princivalle 
wrote:
>
> So this part:
>         <div id="fb-root"></div>
>         <script>(function(d, s, id) {
>           var js, fjs = d.getElementsByTagName(s)[0];
>           if (d.getElementById(id)) return;
>           js = d.createElement(s); js.id = id;
>           js.src = "//
> connect.facebook.net/it_IT/sdk.js#xfbml=1&version=v2.0";
>           fjs.parentNode.insertBefore(js, fjs);
>         }(document, 'script', 'facebook-jssdk'));</script>
>  
> Have to be placed in the .load file.
> Yes I've tried also like that, taking off the same script from the layout 
> file.
> The result is the same, the Facebook script load only the first time.
>
> As the Facebook sdk was always giving an ID error I've create an app ID in 
> Facebook and now the new Facebook script is:
> <script>
>   window.fbAsyncInit = function() {
>     FB.init({
>       appId      : 'mypappid',
>       xfbml      : true,
>       version    : 'v2.2'
>     });
>   };
>
>   (function(d, s, id){
>      var js, fjs = d.getElementsByTagName(s)[0];
>      if (d.getElementById(id)) {return;}
>      js = d.createElement(s); js.id = id;
>      js.src = "//connect.facebook.net/it_IT/sdk.js";
>      fjs.parentNode.insertBefore(js, fjs);
>    }(document, 'script', 'facebook-jssdk'));
> </script>
>
> But problem still the same.
> And as there's not a js error I don't know what to do.
>
> An idea?
>
> Il giorno martedì 17 febbraio 2015 17:58:37 UTC+1, Niphlod ha scritto:
>>
>> if you have a piece of script that *depends/works on/does something to* 
>> on elements placed in the LOAD()ed component, you need to initialize the 
>> "piece" inside the LOAD()ed fragment, not on the one containing it.
>>
>> On Tuesday, February 17, 2015 at 10:36:22 AM UTC+1, Gael Princivalle 
>> wrote:
>>>
>>> Hello all.
>>>
>>> I have in a web site a lateral menu with categories that change datas in 
>>> a .load file, displayed in a div, with ajax.
>>> Something like that:
>>> A link in the lateral menu:
>>> {{=A(category.name,callback=URL('prod','prod.load', vars=dict(
>>> category_id=category.id), user_signature=True), target="div_prod")}}
>>>
>>> The div where I display the datas:
>>> {{=LOAD('prod','prod.load', ajax=True, target='div_prod')}}
>>>
>>> It works fine.
>>>
>>> I've add Facebook button's Like and Share without problems in the layout 
>>> like that:
>>> At the beginning of the body:
>>>         <div id="fb-root"></div>
>>>         <script>(function(d, s, id) {
>>>           var js, fjs = d.getElementsByTagName(s)[0];
>>>           if (d.getElementById(id)) return;
>>>           js = d.createElement(s); js.id = id;
>>>           js.src = "//
>>> connect.facebook.net/it_IT/sdk.js#xfbml=1&version=v2.0";
>>>           fjs.parentNode.insertBefore(js, fjs);
>>>         }(document, 'script', 'facebook-jssdk'));</script>
>>>
>>> At the end of the body:
>>>             {{if request.function != 'products':}}
>>>                 <div class="page-content">
>>>                     <div class="container">
>>>                         <div class="fb-like" 
>>> data-href="{{=URL(args=request.args, 
>>> vars=request.vars, scheme=True, host=True)}}" data-layout="button_count" 
>>> data-action="like" data-show-faces="true" data-share="true"></div>
>>>                     </div>
>>>                 </div>
>>>             {{pass}}
>>>
>>> Now I would like to link these buttons to specific products.
>>> I've put a test in the layout for not displaying the facebook buttons if 
>>> the page is "products" .
>>> So I would be able to add these buttons inside the .load file.
>>>
>>> The problem is that there are displayed (so processed by Facebook 
>>> script) only when the complete page product.html is loaded.
>>> If I stay on the products page changing datas in the .load file, buttons 
>>> are not displayed.
>>>
>>> Someone have a solution or almost an explanation ?
>>>
>>> Thanks, regards.
>>>
>>>
>>>
>>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to