}
});
-
-(function () {
-
-
- // Templates used for rendering
- var templateEngine = new ko.jqueryTmplTemplateEngine();
- TemporaryViewModel=function(currentPolicyInformation,selectedOption){
- var self=this;
- this.policyInformation=currentPolicyInformation;
- this.selectedValue=selectedOption;
- isSelectedOption=function(id){
- return (id==self.selectedValue);
- }
- }
- ko.bindingHandlers.proxyConnectorPolicies = {
- update: function(element, valueAccessor, allBindingsAccessor, proxyConnectorViewModel) {
- // This will be called once when the binding is first applied to an element,
- // and again whenever the associated observable changes value.
- // Update the DOM element based on the supplied values here.
- var jqueryElement=$(element);
- $.log("update:"+proxyConnectorViewModel.proxyConnectorsViewModel.managedRepositories().length);
- // Empty the element
- while(element.firstChild) {
- ko.removeNode(element.firstChild);
- }
- var policyInformations = proxyConnectorViewModel.proxyConnectorsViewModel.policyInformations();
- for (i=0;i<policyInformations.length;i++){
- var currentPolicyInformation=policyInformations[i];
- var gridContainer = element.appendChild(document.createElement("DIV"));
- var selectedOption =
- proxyConnectorViewModel.update ?
- proxyConnectorViewModel.getSelectedOptionForPolicy(currentPolicyInformation.id()):currentPolicyInformation.defaultOption();
-
- var tmpViewModel = new TemporaryViewModel(currentPolicyInformation,selectedOption);
- ko.renderTemplate("proxy-connector-edit-form-policies-tmpl", tmpViewModel
- , { templateEngine: templateEngine }, gridContainer, "replaceNode");
- ko.utils.registerEventHandler($("#policy-"+currentPolicyInformation.id()).get(0), "change", function () {
- $.log("change policy:"+$(this).attr('value')+" for policy " + tmpViewModel.currentPolicyInformation.id());
- });
- /*.change(function(event){
- $.log("change policy:"+$(this).attr('value')+" for policy " + tmpViewModel.currentPolicyInformation.id());
- });*/
- }
- }
- };
-})();
\ No newline at end of file
</fieldset>
</form>
</script>
-
-<script id="proxy-connector-edit-form-policies-tmpl" type='text/x-jquery-tmpl'>
- <tr>
- <td>${policyInformation.name()}</td>
- <td>
- <select id="policy-${policyInformation.id()}">
- {{each(i, curOption) policyInformation.options()}}
- {{if isSelectedOption(curOption)}}
- <option selected value="${curOption}">${curOption}</option>
- {{else}}
- <option value="${curOption}">${curOption}</option>
- {{/if}}
- {{/each}}
- </select>
- </td>
- </tr>
-
- <br/>
-</script>
\ No newline at end of file