seaside : 2 events on html anchor

2019-02-24 11:33发布

In seaside I need to do two events - callback and go to the other url (google.com) on clicking a link but I am not able to do both of them. What could be possibly wrong here? Is there any way I can do both the events?

html anchor
    newTarget url: 'www.google.com';
    callback: [Transcript show: 'clicked on google.com'];
    with: ('www.google.com') .

2条回答
Emotional °昔
2楼-- · 2019-02-24 11:56

You cannot use the default click behaviour of an anchor to accomplish this. The code snippet below demonstrates how to do this with an ajax call that executes your action in a callback and sets the navigation to the other url as the ajax 'oncomplete' action.

html anchor
   url: 'javascript:{}';
   onClick: (html jQuery ajax 
                        callback: [ ... ];
                        onComplete:(html javascript goto:'http://www.google.com'));
    with: 'http://www.google.com'.

The snippet cancels the default click action on the anchor using the 'javascript:{}' code as the url. In some cases, I have also seen the use of '#' but in my experience that also scrolls your browser to the top. Next, it sets its proper 'click' handler that launches an ajax request, as I described before.

查看更多
小情绪 Triste *
3楼-- · 2019-02-24 12:15

Because >>callback: and >>url: both update the href attribute on an Anchor tag, you can't use both on the same anchor. You will have to solve this by writing a callback method which executes your logic, and then uses javascript to open the page in a new window.

Hope that helps!

查看更多
登录 后发表回答