On Fri, Apr 7, 2017 at 1:12 PM, Phyambre <phy....@gmail.com> wrote:

> Hi Thiago,
>

Hi!


> Thanks for your email.
>
> 1) I am not using form submissions for that. I am using input hidden
> fields as temporary variables because the input hidden seem to be
> visible from zone-updater.js while the javascript library (not module) I
> am using for the mouse tracking is not, and I don't know why. Should I
> include the library in the "require" of the zone-updater.js? how can I
> do that if it is not in META-INF/assets?
>

Most probably yes. At least it makes everything consistent.


> 2) I read the document you suggest. It seems interesting but I can't
> fully understand it. I think you mean this snippet.
>
> How can I transform it to call my onTrack method when on mouse move
> occurs on any p of a certain class "trackedParagraph"? I don't need to
> process any response since onTrack just saves things in a DB. Maybe
> something like this?
>
> require(["t5/core/ajax", "jquery"], function (ajax, $) {
>     $('p.trackedParagraph').mousemove(function() {
>         ajax('track'), {
>                 mouseX: $('#mouseXField'),
>                 mouseY: $('#mouseYField'),
>                 ...
>                 queryParameterName: $('#fieldName')
>         });
>     });
> });
>
> Would something like that work? Sorry, maybe my problem is that I am not
> familiar with jQuery notation.
>

Yes, I believe you're in the right path, except for a little error in the
line below:
ajax('track'), {
It should be
ajax('track', {

And adding an element: null or element: [some element] to the object you're
passing as the second parameter of ajax().


> And more important. Will this avoid calling onActivate() again on the
> page? Because my current solution seems to work, but the biggest
> efficiency problem is that every AJAX call executes onActivate().
>

No. onActivate() is called for every request to the page, regardless if
it's an event or page render one. You need to remove the expensive code
from onActivate(), or at least only call it when needed. You haven't posted
any Java code or pseudocode, so it's hard to help you further.

-- 
Thiago

Reply via email to