Announcement Announcement Module
Collapse
No announcement yet.
how to fire an event on self.close() in javaScript? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • how to fire an event on self.close() in javaScript?

    Hi,

    I have one requirement where in I have to fire an event on self.close() on a jsp page and capture that event in flow.xml.

    e.g. I am trying to do something like this.
    self.close("&_eventId=test"); This should fire a new event called test and then this event should be available in flow.xml.

    I tried to implement this but it didn't work. Does anyone have any idea how do I implement this?

    Thanks,

  • #2
    The nice way, using spring.js (which must be added in your header)
    Code:
    my.spring.triggerEvent = function (formId, eventId) {
    	var params = {};
    	params["_eventId"] = eventId;
    	Spring.remoting.submitForm("_eventId", formId, params);
    };
    or
    Code:
    my.spring.triggerEvent = function (formId, eventId) {
    	var sourceId = "_eventId_" + eventId;
    	var params = {};
    	params[sourceId] = sourceId;
    	Spring.remoting.submitForm(sourceId, formId, params);
    };
    Or the other way is to trigger it yourself (without including Spring.js):
    Code:
    function triggerEvent(formId, event) {
    	var form = document.getElementById(formId);
    	if (form) {
    		var hidden = document.createElement('input');
    		hidden.type = 'hidden';
    		hidden.name = '_eventId';
    		hidden.value = event;
    		form.appendChild(hidden);
    		form.submit();
    	}
    }
    I have tried them when closing the page, but I guess it should work.

    Comment

    Working...
    X