I have added a simple workflow view to my application which I want to dynamically update whenever a permit is created with status pending. I have the basic mechanics working, but I am stuck getting it cleaned up. I followed the patterns laid out in "Evening with CB", so this should look familiar.
Here's the workflow.html: <html><head> <title>New Permits!</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/ 1.7.0/jquery.min.js"></script> <script> function listen_for_events(timestamp) { $.ajax("/permit/pull/" + timestamp, { success: function (data, code, xhr) { for (var i=0; i<data.permits.length; i++) { //var msg = data.permits[i].permitid; var msg = data.permits[i]; //$("#permits_list").append("<div> <a href=\"/permit/view/{{ permit.id }}\">permit_id</a>+msg </div>"); $("#permits_list").append("<li>"+msg); } listen_for_events(data.timestamp); } }); } $(document).ready(function() { listen_for_events({{ timestamp }}); }); </script> </head> <body> <ul id="permits_list"> {% for permit in permits %} <li><a href="/permit/view/{{ permit.id }}">{{ permit.id }} {{ permit.approval_status }} {{ permit.create_date }} {% empty %} <li>No permits! {% endfor %} </ul> </body> </html> Here's the relavent section of the controller: pull('GET', [LastTimestamp]) -> { ok, Timestamp, Permits } = boss_mq:pull("new-permits", list_to_integer(LastTimestamp)), {json, [{timestamp, Timestamp}, {permits, Permits}]}. When I use data.permits[i].permit_type it prints "raffle", but I would like a hyperlink that I can use to open the edit screen. When I use data.permits[i].permit.id or permit_id it prints "undefined". When I try to dump the contents with data.permits[i] I get [object Object]. Here's a snippet of the workflow page: - permit-52b30441b467e80453000005 pending {1387,442145,0} <http://localhost:8001/permit/view/permit-52b30441b467e80453000005> - permit-52b3046db467e80453000006 pending {1387,442189,0} <http://localhost:8001/permit/view/permit-52b3046db467e80453000006> - permit-52b304b5b467e80453000007 pending {1387,442261,0} <http://localhost:8001/permit/view/permit-52b304b5b467e80453000007> - permit-52b30599b467e80453000008 pending {1387,442489,0} <http://localhost:8001/permit/view/permit-52b30599b467e80453000008> - [object Object] Ideas? -- You received this message because you are subscribed to the Google Groups "ChicagoBoss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
