GrabTemplates giving an error on html fragment containing templates
Opened this issue · 5 comments
I have a complex user-interface inside a window (pop-up) and window content is a dynamically loaded html fragment.
The process is following
- GET to the server to return window content
- render content to the container
- ich.GrabTemplates()
- do stuff
- display the window
The problem is that when I open the window two or more times I get an error for each template that is used in the window.
Invalid name: dialogTitle. ICanHaz.js:472
ich.addTemplate
I understand that the problem is that the template is already "grabbed", but is there anyway to tell ICanHaz to either skip or override existing templates? There are quite many templates in the window, so it would be really nice if I could still use GrabTemplates and not manually check the existence and then add template if it doesn't exist in the ICanHaz.
This is slightly related to the issue opened by tonynoy #44
Sorry this has been sitting forever. We could do something like this. I could see it being useful. I'd consider it if you have the time to write the code and send a PR.
It seems like grab templates should take an option {ignoreDuplicates: true}
.
Sorry for not doing the fix. This has been in my mind even thou I have
working in a project that is not using ICanHaz. :)
What if template has been updated and it has a same id? We would then
override template with the latest. Should the option be: {
overrideDuplicates: true } or silently update it without error?
On 27 May 2013 18:21, Henrik Joreteg notifications@github.com wrote:
It seems like grab templates should take an option {ignoreDuplicates:
true}.—
Reply to this email directly or view it on GitHubhttps://github.com//issues/51#issuecomment-18503565
.
Same problem here.
I am building a full AJAX single page web app and new templates are grabbed at each ajax call just after injecting the HTML. So going back to a page already visited results in "Invalid name" errors in console as these templates already exist.
I think ICaNHaz should override duplicates by default.
People using same templates IDs on the same page, well, go to hell
I prefer being explicit in failing if there is one. But it would be easy enough to have it take an option to silently overwrite them. I stand by my original suggested fix. Can't do it right now, I've got 40 other things going at once, but a PR on this would get merged.