简体   繁体   English

Deeplinking JSON数据加载

[英]Deeplinking json loaded data

I have json data that is populating the dom and the json objects being added have IDs that are used for the window.hash 我有填充dom的json数据,正在添加的json对象具有用于window.hash的ID

       $j.getJSON('js/looks.json', function(data){

            $j.each(data.looks, function(i, looks){
                var look = "<li class='style "+data.looks[i].type+"'>";
                look+= "<div class='overlay'></div>";
                look+= "<a href='#"+data.looks[i].person+"'><img src='../images/looks/landinglooks_"+data.looks[i].person+".jpg'/></a>";
                look+="</li>";
             });

      });

and the div this is linked to is output in json aswell: 与此链接的div也在json中输出:

<div id='"+data.looks[i].person+"' class='block steps'>

Outputs: 输出:

<li class="style fine"><div class="overlay"></div><a href="#gabrielle"><img src="../images/looks/landinglooks_gabrielle.jpg"></a></li>

Clicking this brings you to http:.../#/gabrielle which is a div that is also 单击此按钮会将您带到http:... /#/ gabrielle,这是一个div,

<div id="gabrielle" class="block steps"></div>

This works fine, but it seems like on page load (if I try to load to .../#/gabrielle) nothing happens. 这可以正常工作,但是似乎在页面加载(如果我尝试加载到... /#/ gabrielle)上什么都没有发生。 jQuery Address doesn't read the hash on pageload for the json loaded into the dom. jQuery Address不会读取加载到dom中的json的页面加载时的哈希值。

Is there a workaround or another deeplinking plugin that supports this? 有解决方法或其他支持此功能的深层链接插件吗?

I decided to use http://benalman.com/projects/jquery-hashchange-plugin/ worked like a charm! 我决定使用http://benalman.com/projects/jquery-hashchange-plugin/就像一个魅力! I can call the hashchange trigger after the json is loaded. 加载json后,我可以调用hashchange触发器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM