Notice

The forum is in read only mode.

Support Forum

Welcome! Support Forums have been reactivated
Welcome the Technical Support section. Help us in assisting you by providing us with a concise and descriptive elaboration of your issues. Be specific and if possible, provide us with a step-by-step instruction in replicating your problem.

How to add Popup Window at ajaxApproveInvite

2 years 4 months ago
Licenses:
JomSocial Active GURU Active Publisher Active AdAgency Active iSEO Active Socialize Active

ISSUE SUMMARY:
I need to create more complex logic for guest event participation approval. The logic is done and works well, but I am looking for a way how I can show the result of my internal check as popup window while the system process ajaxApproveInvite method in /com_community/controllers/events.php

I am trying to find a way how I can create a popup window based on my calculation and I need your help here.

I place code as follows:
At the beggining of the function there was a line as follows:
$response = new JAXResponse();

At the end of the code I put the line as follows:
$response->addScriptCall('cWindowShow', $header, $message, 450, 300, 'warning');

where $header and $messages are 2 strings defined before. But the systems doesn;t show any popup window..

I tried to use the following code just before the end:
$json = array(
'title' => JText::_('COM_COMMUNITY_EVENTS_REQUEST_APPROVED'),
'html' => $contents,
'btnYes' => JText::_('COM_COMMUNITY_YES_BUTTON'),
'btnNo' => JText::_('COM_COMMUNITY_NO_BUTTON')
);
die( json_encode($json) );
But got nothing.

Please provide any guidance how I can get a popup window at ajaxApproveInvite?

2 years 4 months ago
  • Dimas's Avatar
  • Dimas
  • Visitor
  • Thank you received: 0
Licenses:

HI Vlad,

You also need to change the javascript trigger, I suggest you compare the code with reject button, reject button call this function eventRejectGuest to show the popup first.

well, this hack is really complicated and not easy one, you need to have good knowladge on PHP and Javascript.

thank you!

2 years 4 months ago
Licenses:
JomSocial Active GURU Active Publisher Active AdAgency Active iSEO Active Socialize Active

I am good in development on PHP but with JavaScript I am not always sure.

For ApproveGuest the JS code is as follows:
onclick="joms.api.eventRejectGuest('152', '484');"

while for ApproveInvite:
onclick="jax.call('community','events,ajaxApproveInvite','484' , '152');"

For me, for Approve - it is clear how the system comes at ajaxApproveInvite function at event.php but for eventRejectGuest - this is not clear at all. If I replace jax.call on joms.apa.eventApproveInvite, where I need to add a call for the ajaxApproveInvite ands where can I set a hook for eventApproveInvite?

Thx, Vlad.

2 years 4 months ago
  • Dimas's Avatar
  • Dimas
  • Visitor
  • Thank you received: 0
Licenses:

Hi Vlad,

Please you look this file components/com_community/assets/source/js/popups/event.rejectguest.js
and function eventRejectGuest on this file
components/com_community/assets/source/js/api.js

our Javascript developer use high level code, so its really hard to be followed :) but you can learn on it :)

thank you!

2 years 4 months ago
Licenses:
JomSocial Active GURU Active Publisher Active AdAgency Active iSEO Active Socialize Active

It would be great if you ask him for an advise. I learned the code and now I understand the whole logic better. Anyway, it would be great if your JS developer share any thoughts here.

Thx, Vlad.

2 years 4 months ago
Licenses:
JomSocial Active GURU Active Publisher Active AdAgency Active iSEO Active Socialize Active

I just need to understand better how "joms.api.eventRejectGuest('152', '484');" is linked with the event.rejectguest.js file and how and where you include this js script file into the php page?

2 years 4 months ago
  • Dimas's Avatar
  • Dimas
  • Visitor
  • Thank you received: 0
Licenses:

Hi Vlad,

Our javascript developer will give you the example code (the easy method), please stay tuned :)

thank you!

2 years 4 months ago
Licenses:
JomSocial Active GURU Active Publisher Active AdAgency Active iSEO Active Socialize Active

Guys, I need your help. I arrived with creation several changes as follows:
1) I added a block about my new JS function in the components/com_community/assets/source/js/api.js. As far as I understand, this file is loaded from loader.js... Hereby are changes:

... something existing before ...

/** Events. */
   eventApproveInvite: function( id, userId ) {
        joms.popup.event.approveInvite( id, userId );
    },

... something existing before ...

2) I added a new file which provides popup functionality here: components/com_community/assets/source/js/popups/event.approveInvite.js
3) I added registration of the file into another file, which is called from api.js, as far as I understand: components/com_community/assets/source/js/popups/events.js, in define I added a line as follows:
define([
.... something existing before ....
'popups/event.approveinvite',
... something existig before ...
    ], function() {
        return joms.popup.event;
    });

The file, which is a part of the JomSocial template (events.viewgues.php) has been changed by adding to the button the JS code as follows:
onclick="joms.api.eventApproveInvite('<?php echo $eventid; ?>' , '<?php echo $guest->id; ?>');"

But still, the debuger says that the function joms.api.eventApproveInvite is unknown, while another function which is on top of the problematic one joms.api.eventRejectGuest doesn't have any problem.

So, my conclusion, you registered such a function a specific way, how and where? Which file more have I updated by adding declaration of joms.api.eventApproveInvite function?

I attached the result code of event.approveinvite.js file just to illustrate that it should work. So I still blocked and cannot get control in ajaxApproveInvite function while click on Approve button on the page of task=viewguest, so, please help.

Thank you in advance, Vlad.

2 years 4 months ago
  • Dimas's Avatar
  • Dimas
  • Visitor
  • Thank you received: 0
Licenses:

Hi Vlad,

Here is some helps from our javascript developer, you can call the the javascript code with this code



and on controller file, put this code



I hope it will help

Cheers! ;)

Attachments:
2 years 4 months ago
Licenses:
JomSocial Active GURU Active Publisher Active AdAgency Active iSEO Active Socialize Active

I've finally got access into ajaxApproveInvite at events.php with the use of the example of code. Just need a bit more tie to complete the task and as soon as I finish, I update the ticket status.

So far, thank you very much for the support, Vlad.

2 years 4 months ago
  • Dimas's Avatar
  • Dimas
  • Visitor
  • Thank you received: 0
Licenses:

you're welcome,and good luck :)

2 years 4 months ago
Licenses:
JomSocial Active GURU Active Publisher Active AdAgency Active iSEO Active Socialize Active

Hello Guys, the example really helps, but I am a bit confused with different methods of JavaScript usage in different functions, so I need some guidance.

For my method a simple message is not enough, I have to return html code in some cases with form. Different buttons like Yes, No or done, can be in place.

1. My first problem, when I created my code based on the example, I didn't realize that I have to replace symbols " with \'... well, if you provide more advises about the concretion or just provide a reference for a function or methods you use, it would be great.

2. Second thing - in the php of events.php I saw many times the use of code as follows:

        $actions = '<button class="btn" onclick="cWindowHide();">' . JText::_('COM_COMMUNITY_NO') . '</button>';
        $response->addAssign('cwin_logo', 'innerHTML', $header);
        $response->addScriptCall('cWindowAddContent', $message, $actions);
        return $response->sendResponse();
I tied to use the same code in my case but with no luck - the system reports, there is no function cWindowAddContent and cWindowHide. I believe those functions are defined somehow in your library but it would be great to get guidance how I can use them in my case, if it is possible.

3. In my popup window, I need to define a "No" button, which simply closes the dialog, what is the best method to do so?

4. Finally, I saw the use of json array for the same case in events.php, with the line of code as follows at the end:
die( json_encode($json) );
Can you provide any guidance how one can use this method in my case?

Pleaase provide any guidance, may be sending directly at my email any info or docs. My email is as follows info at liatoss dot com.

Thank you in advance, Vlad.

2 years 3 months ago
Licenses:
JomSocial Active GURU Active Publisher Active AdAgency Active iSEO Active Socialize Active

As I didn't get any additional help, I want to share my knowledge based on real experience working with the code of JomSocial. Hereby are my comments on questions, which were published above:
1. This is the most important question from all others. The problem is as follows - we prepare HTML code to tranfer it inside of JavaScript. In such a case, we are to prepare the code by removing \r \n characters and by adding characters to symbols like ' or ". There are several links which can help anyone in writing such a case as follows:
1.1 http://stackoverflow.com/questions/3986299/how-to-remove-new-lines-and-returns-from-php-string
1.2 http://stackoverflow.com/questions/3986299/how-to-remove-new-lines-and-returns-from-php-string
Based on those links, I removed from the HTML code all \n \t \r characters and add slashes based on the article from here:
http://stackoverflow.com/questions/5298776/clean-php-output-into-javascript
Those 3 operations help a lot.
2. Without good knowledge of how the Jos team supports such functions, it is difficult to use the, So, I need more info from JOS team.
3. It is quite simple, I just added a style 'joms-js--button-close' for "No" button and it does the magic.
4. Well, it is a way how to return the code from php into JavaScript. For the moment I stay with the method, which was suggested by JOS team above.

Anyway, I would say the support is not so good, but it helps me to solve my problem with losing time on investigation on my side. WiKi and Developers documentation are nothing to help here.

Thank you again the JOS team,
Vlad.

Moderators: Piotr Garasiński
Powered by Kunena Forum

Join 180,000 websites creating Amazing communities

JomSocial is the most complete, easy-to-use addon that turns Joomla CMS into a
full -fledged, social networking site

TRY NOW BUY NOW