jDrupal icon indicating copy to clipboard operation
jDrupal copied to clipboard

How to properly use the pre/post process callbacks?

Open hanoii opened this issue 7 years ago • 2 comments

Do I need to add something manually to jDrupal.modules for it to be picked up and then just define a function in the global scope?

so would it be:

  1. jDrupal.modules['something'] and then

2.function something_rest_pre_process(xhr, data) {} on the global spec?

Is 1 necessary?

hanoii avatar Jun 23 '17 15:06 hanoii

@hanoii Yes, step no. 1 is necessary. Perhaps we should add something like jDrupal.addModule(); (and some corresponding docs) to make this more intuitive. Not many people get into jDrupal custom modules, 99% of the time people are using jDrupal by way of DrupalGap, and the usage of modules that way is much more well documented. Then we could have something like:

jDrupal.addModule('something');
function something_rest_pre_process(xhr, data) {
  // Do something...
}

Your thoughts?

signalpoint avatar Jun 27 '17 03:06 signalpoint

that's fine although it was mainly lack of documentation.

As for further thoughts/preference I would have preferred something that doesn't require me to add it to the global spec.

Maybe using javascript events.

Or, if you want to still add it to jDrupal, maybe do it in a way similar to Drupal.behaviors where what you add there has the methods self-contained.

But this could possible mean quite a in the logic for you I guess and as you say is for little uses.

hanoii avatar Jun 27 '17 12:06 hanoii