Topic: How do I code Javascript unobstru..unostrub...unobs..uno..u n o b t r u s i v e l y |
|
---|---|
Author | Thread |
Bipolar (III) Inmate From: you tell me |
posted 07-02-2008 11:13
Hi guys, code: string = ''; for($i=0;$i<$rs;$i++) string .= _createRow($rs[$i]); function _createRow($data) { $xhtml = '<div id="rowid'.$data['id'].'" >'.$data['name'].' - Contact Details:'.$data['contact'].'</div>'; $xhtml .= '<a href="#" onclick="deleteContact('.$data['id'].')">delete</a>'; return $xhtml; }
|
Paranoid (IV) Inmate From: Norway |
posted 07-02-2008 11:33
Indeed, Chris Heilmann really knows his thing about unobstrive JavaScript and accessibility. And he's a cool guy too. code: function _createRow($data) { $xhtml = '<div id="rowid'.$data['id'].'" >'.$data['name'].' - Contact Details:'.$data['contact'].'</div>'; $xhtml .= '<a href="/contact/'.$data['id'].'/delete">delete</a>'; return $xhtml; } When the load event of the page kicks in, look for the links using your REST API and AJAXify them at will. |
Bipolar (III) Inmate From: you tell me |
posted 07-02-2008 11:55
Well thats what gotten me stumped. I mean when teh onload event runs how do I like attach a delete function to teh onclick handler passing it the appropriate values according to the rowset. |
Paranoid (IV) Inmate From: Norway |
posted 07-02-2008 13:24
REST stands for Representational State Transfer. It basically describes a way to access/touch ressource via a (meaninful) URI, a verb ( the HTTP Method, e.g.: GET, POST, DELETE, ... ) and a Content-type. See A brief introduction to REST, REST for the rest of us and How I explained REST to my wife for further explainations. |
Bipolar (III) Inmate From: you tell me |
posted 07-02-2008 15:33
Wait you mean that inorder to get this to work my delete function would have to parse through the object its attached to and retrieve information from its attributes via some kind of pattern matching scheme...is that uh.. safe? COnsidering that a user might be able to change the attributes of teh A tag using firebug...etc. |
Paranoid (IV) Inmate From: Norway |
posted 07-02-2008 16:04
Mind you that pattern matching scheme does not necessarily mean RegExp. It can be more trivial/hardcoded than this. |
Bipolar (III) Inmate From: you tell me |
posted 07-03-2008 08:20
hmmmm.... got a point there - are there any easy to follow examples around which could get me jump started.. examples which tackel normally encountered situations. |