1
0
-1

I would like to add a click listener to an anchor element. The click listener would make a DDS call which would return a URL, which then opens in a new window/tab.

  1. Ben Warner

    Can you clarify which component type you want to add the rule to? I'm not aware of an Anchor component.

  2. Yulius Gita

    I am using the text display element and use the anchor link in the label.

CommentAdd your comment...

1 answer

  1.  
    2
    1
    0

    Add a hidden Dynamic Data Button to your form that opens the URL in a new window in the onSuccess rule.

    In your anchor tag add javascript to the href to call the click rule of the Dynamic Data Button, e.g. 

    <a href="javascript:
    $('Form').scope().Form.fireRule('click','button',$('Form').scope().Form.data)">Click Me</a>
    1. Yulius Gita

      Ben Warner, I had used a different way, by using the click rule of the text display field and tweaked the CSS. Your suggestion looks cleaner, I would give this a go and update. Thanks.

    2. Yulius Gita

      Just tried this and there is an error when clicking the anchor link:

      anchor element DOM:

    3. Yulius Gita

      Thanks Ben, that works.

      I have now placed the text display field inside a repeat and I am unsure how to pass the data to the button click rule.

      I have tried the following:

      1. pass in the required data, documentId (a data field in the repeat)
        <a href="javascript:
        $('Form').scope().Form.fireRule('click','button',$('Form').scope().Form.data,{{data.documentId}})">Click Me</a>
        this adds 'unsafe:' at the front of the href attribute when rendered, i.e. ... href="unsafe:javascript:...".... And clicking on the link does not do anything 
      2. pass in the repeat index
        <a href="javascript:
        $('Form').scope().Form.fireRule('click','button',$('Form').scope().Form.data,$('Form').scope().Form.data.$i)">Click Me</a>
        data.$i is null 
      Any suggestions?
    4. Ben Warner

      I would put the button in the repeat and get the data in the click rule of the button, rather than try to pass it through.

    5. Yulius Gita

      The data object has the repeat data ($i, documentId) when the button click script is invoked by clicking the actual button. However when invoked by the fireRule, the repeat data is missing.

      Clicking the actual button:

      fireRule:

      Is there any function available to return/provide the repeat data?

    6. Ben Warner

      I couldn't get this working in a repeat - did you resolve it?

    CommentAdd your comment...