How to assign an arbitrary event UI?

Develop and Deploy Cross-Browser Web Apps .

How to assign an arbitrary event UI?

Postby Sergei » Tue Jun 18, 2013 5:02 am

Can I assign an arbitrary event that is not in the list of events element UI, assign a handler? How to do it and what is the mechanism of its call?
Is it possible to use the method to setEventHandlers on DataBinder or other UI? If yes, it is possible example.
Sergei
 
Posts: 31
Joined: Sat Apr 27, 2013 9:48 am

Re: How to assign an arbitrary event UI?

Postby support » Tue Jun 18, 2013 8:20 am

   
Class('App', 'xui.Com',{
Instance:{

iniComponents : function(){
// [[Code created by CrossUI RAD Tools
var host=this, children=[], append=function(child){children.push(child.get(0))};

append(
(new xui.UI.SLabel)
.setHost(host,"ctl_slabel1")
.setLeft(60)
.setTop(30)
.setCaption("ctl_slabel1")
.onRender("_ctl_slabel1_onrender")
);

return children;
// ]]Code created by CrossUI RAD Tools
},
_ctl_slabel1_onrender : function (profile){
xui.subscribe("topic", "subscriber", function(msg){
xui.message("received : " + msg);
});

var ns = this, uictrl = profile.boxing();
uictrl.getSubNode("KEY").onClick(function(){
// DOM related event
xui.message("click event on DOM node");

// other events
xui.publish("topic", ["message"]);
});
}
}
});
   
support
 
Posts: 352
Joined: Sat Apr 27, 2013 9:22 am

Re: How to assign an arbitrary event UI?

Postby Sergei » Tue Jun 18, 2013 8:52 am

This is not what we need. If clarify, I want to create an event xui.DataBinder reacting to the method setData object xui.DataBinder (for example onAfterSetData), write your handler.
In general, based on the documentation, create your event and cause it can only heir object xui.Com (method fireEvent). But may have the opportunity to do the same for the object xui.DataBinder?
Sergei
 
Posts: 31
Joined: Sat Apr 27, 2013 9:48 am

Re: How to assign an arbitrary event UI?

Postby support » Tue Jun 18, 2013 9:33 am

Enhance lib function like this:

javascript code
// Add event handler
xui.DataBinder.setEventHandlers({"afterSetData":function(profile,key,value){}})

// Modify setData function to trigger the event
var old=xui.DataBinder.prototype.setData;
xui.DataBinder.plugIn("setData",function(key,value){
old.apply(this,arguments);
this.afterSetData(this.get(0),key,value);
return this;
});


And, you can use:

javascript code
databinder.afterSetData(function(profile,key,value){
// What ever
});
support
 
Posts: 352
Joined: Sat Apr 27, 2013 9:22 am

Re: How to assign an arbitrary event UI?

Postby Sergei » Tue Jun 18, 2013 9:37 am

: D thank you ).
Sergei
 
Posts: 31
Joined: Sat Apr 27, 2013 9:48 am


Return to CrossUI for Web Apps

Who is online

Users browsing this forum: No registered users and 0 guests

cron