sebble / SebbleDMS

Secure data management (PHP, AJAX)
Other
2 stars 2 forks source link

template build problems #29

Open sebble opened 13 years ago

sebble commented 13 years ago

Hi K,

I have noticed that in some situations pages will stop loading, could you narrow this down for me?

You should see an error in the console about template building.

Cheers

keithnewman commented 13 years ago

Do you have any example situations of where this was happening (any particular pages)? Does it just stop responding after a while? Is it for any particular browser?

I'll keep an eye out for this happening and i'll check the console for errors, but I haven't seen it myself so far.

Date: Tue, 23 Aug 2011 04:05:29 -0700 From: reply@reply.github.com To: knewma@hotmail.com Subject: [SebbleDMS] template build problems (#29)

Hi K,

I have noticed that in some situations pages will stop loading, could you narrow this down for me?

You should see an error in the console about template building.

Cheers

Reply to this email directly or view it on GitHub: https://github.com/sebble/SebbleDMS/issues/29

sebble commented 13 years ago

It seems to break just after I modify some JS code or PHP and then I see that error, not very consistent though, a refresh usually fixes it but would lose the clients info. The main place I noticed this was when adding/removing roles and an error like missing parameter would be in the console and the role would have been added but the box would not have reloaded.

sebble commented 13 years ago

Okay, can you reproduce this..!

keithnewman commented 13 years ago

Yes I'm getting your situation in IE8.

I'm also getting the console errors you mentioned: When the page is loaded I get Empty or undefined template passed to $.jqotec jquery.jqote2.js, line 12 character 256 which corresponds to function r(e,x){throw $.extend(e,x),e;}

when you try to edit the new user's details, it throws up 'r' is undefined jquery.jqote2.js, line 14 character 344 Which is of course the function previously mentioned.

I'll keep looking.

sebble commented 13 years ago

I think I've found the cause, although not the solution.

Notice that the "DoB" value reads 'undefined' for new entries (I should possibly define something else as default value), so when the template is built with the values of the new data an error is thrown when that 'undefined' variable is reached.

For some reason, if some full data has already been loaded, then replaced by the row with the missing value the variable name now exists but the value is set to 'undefined' so no error finding this missing variable (because name now defined). I'm not sure quite how this works (i.e. the difference between an undefined variable and a variable with undefined value, or why replacing/updating the row [in JS page memory] keeps the previous (now empty) elements).

Clearly this needs to be fixed. Unfortunately the code <%= undefinedvarname %> is not mine and silently fails in these situations so either the JS template designer must check for existence himself, or reference by window['varname'] instead of window.varname creating a warning (invalid key) rather than error (missing var) but this seems like a bad idea relying on this interpretation. Would it be worth forking https://github.com/aefxx/jQote2 and adding the safety checks? Or should I just use my own function <%= display('varname') %> -- seems silly, or can this situation be avoided by correctly saving the data in the first place (updating PHP code) and noting that this will happen so watch out Mr Template Designer and PHP Implementer.