There used to be a time when I was a JavaScript God. I could blindly type any piece of code in the irt FAQ and could do some pretty neat stuff combining XML, ASP and Javascript.
However, years have passed, libraries evolved and AJAX came to the scene. I regularly read the most interesting developer blogs on these subjects but I have been endulged in many other technical and less technical IT subjects (mostly Siebel, Microsoft or Rational related).
So I set myself a goal to just pick one of these new awesome libraries and start working with it to bring myself again to a certain acceptable level on the new areas around JavaScript.
- I decided to begin with learning JQuery since I’ve heard good stories about this library (I have to start somewhere).
- I decided to write a certain application: an addressbook which does not use a database backend but stores all contacts as text files (so I can edit each contacts using TotalCommander
).
So… I wrote a routine which displays a certain datafolder on my harddisk and shows the directories. Each of these directories is of certain type. E.g. it could hold families, companies, households, martians, linkedin contacts, hyves contacts or any ordering you want. The following image shows you my first draft tree:
The php application is 100% pluggable. Each field of a contact is a plugin. Each directory type is handled by a plugin and each report is a plugin. So a report is generated pretty dynamically independent of content. Below you see how I call $f_name to call a field plugin. The directory types HOUSEHOLD and CATEGORY are pasted in for explanation.
1: while ($cCounter <= $sizeOfArray) {
2: $catname = $arr[$cCounter][CATEGORY];
3: echo '<td colspan="10" class="header">' . $catname . '</td>';
4: while ( ($arr[$cCounter][CATEGORY] == $catname) && $cCounter <= $sizeOfArray) {
5: $hhname = $arr[$cCounter][HOUSEHOLD];
6: while ( ($arr[$cCounter][HOUSEHOLD] == $hhname) && $cCounter <= $sizeOfArray) {
7: echo '<tr>';
8:
9: for ($k=0;$k<(sizeof($settings));$k++) {
10: $f_name = $settings[$k] . '_row';
11: $o_name = $settings[$k];
12: if ($alternate==0) {
13: echo '<td>';
14: } else {
15: echo '<td style="background-color: #f4f4f4; font-family: Consolas, 'Courier New', Courier, Monospace; font-size: 8pt; line-height: 12pt; border-style: none; color: black; overflow: visible; padding: 0px 0px 0px 0px; width: 100%; margin: 0em; background-color: white;">';
16: }
17: echo $f_name($arr[$cCounter][$o_name]) . '</td>';
18: }
19:
20: echo '</tr>';
21: $cCounter=$cCounter+1;
22: } // while the same household
23: if ($alternate==1) {
24: $alternate=0;
25: } else {
26: $alternate=1;
27: };
1: <script type="text/javascript">
2: $(document).ready(function(){
3: // first test for household
4: $("a").filter(".household")
5: .click(function(){
6: $.ajax({
7: url: "household.php",
8: cache: false,
9: success: function(html){
10: $("#report").append(html);
11: }
12: });
13: return false;
14: })
15: .end()
16: });
17: </script>
Obviously this will not work since everything after the “comma” is also passed which means that this filter approach will not work also the ajax function does not pass these parameters.
Oh… I feel so N00b here. Such a simple question “how to pass two parameters in Jquery”… But… fun anyways! If anyone has a clue here please leave me a comment.
