I'm excited about turbolinks3(it allows you to render only a partial and not reload all the body) You can read more about it from here: http://ift.tt/1HDKIqP It's amazing but I've a problem: In browsers that doesn't support pushState(example ie8/9), I don't know how manage the behavior. It give me this error on IE8:
Could not set the innerHTML property. Invalid target element for this operation.
My Controller code is:
def create
@post = Post.find(params[:post_id])
if @post.comments.create(comment_params)
render '_comment', change: [:comments, :super_test], layout: false, :locals => { comment: @post.comments.last }
else
render json:'error'
end
end
A 'solution' could be that I do:
redirect_to @post, change: [:comments, :super_test]
But then the problem is that it reply with a lot of data that I don't need!(and the response time is bigger) So I reallt want find another solution.
How I can resolve this problem ? I've thought about 2 solution: 1) Use history.js / modernizr for polyfill the pushState on old browsers
-
But I've tried but I always get the same error(like if I don't have modernizr)
Webpage error details
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0) Timestamp: Sat, 25 Apr 2015 17:28:52 UTC
Message: Could not set the innerHTML property. Invalid target element for this operation. Line: 26 Char: 30464 Code: 0 URI: http://ift.tt/1Dn902f
2) Find a way for check if the request is done by turbolinks/pjax or not...and use conditional render or redirect_to
- But I've not idea on how I can do it, because turbolinks doesn't send a specific header like does jquery-pjax
Any suggestions ? I really appreciate it!
PS: Please don't suggest me backbone/angular/ember/react, I already know them(backbone), but I want try turbolinks.
Aucun commentaire:
Enregistrer un commentaire