如何触发功能渲染后的模板 [英] How to trigger function after render template

查看:159
本文介绍了如何触发功能渲染后的模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用木偶在我的应用程序。我显示 ItemView控件地区如以下。

I am using marionette in my application. I am showing ItemView through regions like in the following.

var productInfoViewObj=new productInfoView.ProductInfoView({model:tagInformationModel.tagInformationModelObj});
exports.MyApp.bodyContainer.show(productInfoViewObj);

这是code,I 视图里面写

   exports.ProductInfoView=Backbone.Marionette.ItemView.extend({
        domInfo:{
            mainTemplateId:"tagProductListTpl",
            tableTemplateId:"taginfoViewTpl",
            tableContentDiv:"taginfoViewDiv",
            //tad Info
            tagInfoTabId:"tagInfoBtn",
            productInfoTabId:"productInfoBtn"
        },
        template:function(){
            return commonFunctions.templateCompilation("tagProductListTpl","");
        },
        onRender:function(){
            console.log(document.getElementById("productInfoBtn"));
        }
    });

我传递 templateId和数据作为参数传递给 commonFunctions.templateCompilation 。这将编译并返回编译字符串。这编译的结果传递给模板

I am passing templateId and data as arguments to commonFunctions.templateCompilation. It will compile and return compiled string. That compiled result passing to template.

按我的设想,模板完成后的OnRender 功能将被触发。我以前的OnRender 的意思是,DOM将可无论我们使用模板模板化

As per my assumption, after completion of template, onRender function will trigger. What I mean before onRender, dom will available whatever we are templating using template.

但我正在逐渐的OnRender 功能。

我要回调,应该模板DOM 后可触发。这样我就可以访问任何我使用模板

I want a callback, it should trigger after template available in dom. so I can access elements whatever I templated using template.

我可以做一件事情,无论我在的OnRender 写的,我可以设置时间如以下方式

I can do one thing, whatever I written inside onRender, I can setup time like in the following way.

 onRender:function(){
    setTimeout(function(){console.log(document.getElementById("productInfoBtn"));},1000);
 }

如果我设置时间,做工精细,但它不执行正确的方法。

If I set time, working fine but it's not correct way to implement.

谁能帮助我。

感谢。

推荐答案

它解决了,我必须使用昂秀而不是的OnRender 的功能。现在,它的正常工作。

It's resolved, I have to use onShow instead of onRender function. Now it's working fine.

这篇关于如何触发功能渲染后的模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆