我试着在我的页面中加载带有ajax的Disqus,我会解释.我有一个页面,我有jqrusel,有不同的图像,每个都有它的评论.
所以,当我点击其中一张图片时,我已经完成了这段代码:
$.get("/sets/comentarios",{set_id:set_id},function(data){
$("#componet_comentarios").html(data);
Run Code Online (Sandbox Code Playgroud)
这个网址加载:
var disqus_identifier = 'votar-<?= $id; ?>';
var disqus_url = 'www.mitrendy.com/votar/<?= $id; ?>';
// Remove the old script if it's found
oldDsq = document.getElementById('MitrendyComentDisqus');
if(oldDsq) {
(document.getElementsByTagName('head')[0] ||
document.getElementsByTagName('body')[0]).removeChild(oldDsq);
}
(function() {
var dsq = document.createElement('script');
dsq.type = 'text/javascript';
dsq.async = true;
dsq.id = "MitrendyComentDisqus-<?= $id; ?>";
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
Run Code Online (Sandbox Code Playgroud)
但永远不要刷新评论.后来我在disqus的官方页面中看到:
DISQUS.reset({
reload: true,
config: function () {
this.page.identifier = "newidentifier";
this.page.url = "http://example.com/#!newthread";
}
});
Run Code Online (Sandbox Code Playgroud)
但它是一样的,当我试图用ajax加载评论时,永远不要刷新它.
任何的想法 …
我正在尝试加载选项卡组件内的组件以进行反应。这个想法是有一个带有以下语法的 json (或更好的 yaml):
interface TabType {
name: string;
components: string[];
}
interface Templates {
tabs: TabType[];
}
const templateTabsModules: Templates = {
tabs: [
{
name: "Title for Tab 1",
components: ["./components/OneComponent"]
},
{
name: "Title for Tab 2",
components: ["./components/TwoComponent"]
}
]
};
Run Code Online (Sandbox Code Playgroud)
因此,在主组件内部执行以下操作:
<Tabs id="tab">
{templateTabsModules.tabs.map(tab => {
return (
<Tab title={tab.name}>
<p>The component should appears bellow:</p>
<Suspense fallback={<div>Loading</div>}>
{tab.components.map(component => {
const Comp = lazy(() => import(component));
return (<Comp />)
})}
</Suspense>
</Tab>
);
})}
</Tabs> …Run Code Online (Sandbox Code Playgroud) 我想在服务Symfony2上做一个功能测试.这个想法是之前调用控制器,然后使用该函数加载服务.功能就是这个:
function save($title,$description,$setId,$html,$validate,$articles){
$articles = explode(',', $articles);
if (false === $this->container->get('security.context')->isGranted('ROLE_USER')) {
throw new \Exception("Not allowed");
}else{
$profileId = $this->container->get('security.context')->getToken()->getUser()->getId();
$userName = $this->container->get('security.context')->getToken()->getUser()->getUserName();
}
}
Run Code Online (Sandbox Code Playgroud)
现在我的测试代码是:
$client = static::createClient();
$crawler = $client->request('GET','/sets/save',
array(
"title"=>"rtyui",
"description"=>"aksdjhashdkjahskjdh",
"set_id"=>"",
"html"=>"",
"validate"=>1,
"articels"=>"3,4"
)
);
Run Code Online (Sandbox Code Playgroud)
但是我已经没有这条线了:
if (false === $this->container->get('security.context')->isGranted('ROLE_USER')) {
throw new \Exception("Not allowed");
Run Code Online (Sandbox Code Playgroud)
现在,问题是,我如何进行验证过程?我试图做这个验证过程,如显示文档:
$client = static::createClient(array(), array(
'PHP_AUTH_USER' => 'username',
'PHP_AUTH_PW' => 'pa$$word',
));
Run Code Online (Sandbox Code Playgroud)
但我得到了同样的错误.