Hi,
tried to google and search the forums for this, but really can't understand. We need to attach event listener to the datatable's onRowSelected event. This can be achieved using:
<p:ajax event="rowSelect" onstart="myJavascriptThingToRun();" />
But this does a submit that is not needed. How can I prevent the submit and just run the JS when user has selected a row?
- Ville
Ps. We're using 3.0.M2. Also, I tried this: http://primefaces.prime.com.tr/forum/vi ... f=3&t=1373, but the widget does not have function subscribe.
Datatable how to register clientside only behaviour?
-
- Prime
- Posts: 18616
- Joined: 05 Jan 2009, 00:21
- Location: Cybertron
- Contact:
Code: Select all
<p:ajax event="rowSelect" onstart="myJavascriptThingToRun();return false;" />
One problem I don't really like - onlick has the entire bunch of not necessary code after return false; Something like PrimeFaces.ab({formId:'j_idt43',source:'j_idt43:j_idt50',process:'@all',update:'j_idt43:panel ...
We need something to attach only client side callbacks without "dirty" code.
We need something to attach only client side callbacks without "dirty" code.
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin
Cagatay, what do you think about a new behavior for client-side callbacks (handlers) without ajax calls? I mean e.g.
which doesn't generate Ajax stuff like p:ajax. We don't need onstart, oncomplete, etc. then in p:command. I have a lot of use cases where no ajax calls are needed, but at the moment ajax code is always generated in markup. The generated code will be cleaner and we could add more fancy attributes to p:command which are quite usefull (doesn't make sense to add them to p:ajax).
Not sure about name, maybe p:handler or p:callback sounds better.
Code: Select all
<p:command event="rowSelect" handler="myJavascriptThingToRun()" />
Not sure about name, maybe p:handler or p:callback sounds better.
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin
-
- PrimeFaces Core Developer
- Posts: 3979
- Joined: 03 Dec 2010, 14:11
- Location: Bavaria, DE
- Contact:
+1
but "before" and "after" handler methods would be great
but "before" and "after" handler methods would be great
Thomas Andraschko
PrimeFaces | PrimeFaces Extensions
Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE
Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko
PrimeFaces | PrimeFaces Extensions
Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE
Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko
Can we not write
?
By the way, we have much more events for p:command than for a:ajax. We can use all possible jQuery events. At the moment I'm wondering how I can register onclick event on any datatable row in order to show a context menu. I know about future integration of context menu; that was just an example.
Code: Select all
<p:command event="rowSelect" handler="myBeforeFunction(); myJavascriptThingToRun(); myAfterFunction();" />
By the way, we have much more events for p:command than for a:ajax. We can use all possible jQuery events. At the moment I'm wondering how I can register onclick event on any datatable row in order to show a context menu. I know about future integration of context menu; that was just an example.
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin
-
- PrimeFaces Core Developer
- Posts: 3979
- Joined: 03 Dec 2010, 14:11
- Location: Bavaria, DE
- Contact:
hmm i mean, what is if you need a JS before the event and another JS after the event was triggered?
Thomas Andraschko
PrimeFaces | PrimeFaces Extensions
Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE
Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko
PrimeFaces | PrimeFaces Extensions
Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE
Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko
Yes, I meant the same. In the example above myBeforeFunction() is an JS function called before the onlick event on a row (= rowSelect). myAfterFunction() is called after
You probably think about onstart, onsuccess, etc. callbacks. But <p:jsCommand .../> (a good candidate for the extension project ) doesn't trigger ajax requests, they don't make sense here.
You probably think about onstart, onsuccess, etc. callbacks. But <p:jsCommand .../> (a good candidate for the extension project ) doesn't trigger ajax requests, they don't make sense here.
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin
-
- PrimeFaces Core Developer
- Posts: 3979
- Joined: 03 Dec 2010, 14:11
- Location: Bavaria, DE
- Contact:
for example:
wizard navigate - maybe it is required to call JS before the navigation started and after the navigation was finished?
Puh! Don't know if it easy to build such an component in a extension project? Isn't it required to change primefaces JS?
wizard navigate - maybe it is required to call JS before the navigation started and after the navigation was finished?
Puh! Don't know if it easy to build such an component in a extension project? Isn't it required to change primefaces JS?
Thomas Andraschko
PrimeFaces | PrimeFaces Extensions
Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE
Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko
PrimeFaces | PrimeFaces Extensions
Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE
Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko
-
- Information
-
Who is online
Users browsing this forum: No registered users and 45 guests