1 | <% |
---|
2 | /** |
---|
3 | * wizard refresh flow action |
---|
4 | * |
---|
5 | * When a page (/ partial) is rendered, any DOM event handlers need to be |
---|
6 | * (re-)attached. The af:ajaxButton, af:ajaxSubmitJs and af:redirect tags |
---|
7 | * supports calling a JavaScript after the page has been rendered by passing |
---|
8 | * the 'afterSuccess' argument. |
---|
9 | * |
---|
10 | * Example: af:redirect afterSuccess="onPage();" |
---|
11 | * af:redirect afterSuccess="console.log('redirecting...');" |
---|
12 | * |
---|
13 | * Generally one would expect this code to add jQuery event handlers to |
---|
14 | * DOM objects in the rendered page (/ partial). |
---|
15 | * |
---|
16 | * @author Jeroen Wesbeek |
---|
17 | * @since 20120123 |
---|
18 | * |
---|
19 | * Revision information: |
---|
20 | * $Rev: 67320 $ |
---|
21 | * $Author: duh $ |
---|
22 | * $Date: 2010-12-22 17:49:27 +0100 (Wed, 22 Dec 2010) $ |
---|
23 | */ |
---|
24 | %> |
---|
25 | <script type="text/javascript"> |
---|
26 | function onPage() { |
---|
27 | // add waitForLoad class to ajax elements |
---|
28 | $('.ajax').each(function() { |
---|
29 | var that = this; |
---|
30 | var element = $(this); |
---|
31 | var elementId = this.getAttribute('id'); |
---|
32 | element.addClass('waitForLoad'); |
---|
33 | |
---|
34 | $.getJSON(baseUrl+"/ajax/"+elementId,{},function(data) { |
---|
35 | var options = '<h2>'+that.getAttribute('name')+'</h2>'; |
---|
36 | for (var i=0;i<data.length;i++) { |
---|
37 | options += '<input type="checkbox" name="species[]" value="'+data[i].id+'"/>'+data[i].name+'<br/>'; |
---|
38 | } |
---|
39 | element.removeClass('waitForLoad').html(options); |
---|
40 | |
---|
41 | // bind check event handlers |
---|
42 | $('input:checkbox', element).each(function() { |
---|
43 | $(this).bind('change', function() { |
---|
44 | handleCheckEvent(this); |
---|
45 | }); |
---|
46 | }); |
---|
47 | }); |
---|
48 | }); |
---|
49 | } |
---|
50 | </script> |
---|
51 | |
---|