NetTalk Central

Author Topic: Call Nettalk Form - JQuery UI Dialog from a Scheduler Javascript Library  (Read 14704 times)

valicgordon

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Hi, I have a strange issue.

I have a form that I call in an external library:
BookingForm = Nettalk form
                 
var tag1 = $("<div></div>");
$.ajax({
url: "BookingForm?sessioncode="+id+"&staffid="+ev.section_id+"&itemid="+ev.section4_id+"&resourceid="+ev.section2_id+"&equipmentid="+ev.section3_id+"&startdate="+ev.start_date+"&enddate="+ev.end_date,
success: function(data) {
tag1.html(data).dialog({modal: true, height: 750, width: 550, close: function(event, ui) { DoCloseEvent(); }    }).dialog('open');         
             } // success funtion
    });  //close this ajax      


This opens the form in a popup (jquery dialog).  Great!

Issue is it opens with a Javascript Error 'Error in Site Javascript) as well as opening very slow ( it appears to be loading all.js when opening the dialog - taking bulk of the time)

If I call the same form from within nettalk, No Error.

Any help appreciated,

Oh, using ver 2.68, at this time , upgrade not an option.




Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11244
    • View Profile
Hi Sylvester,

>> ver 2.68

confirm please?

>> Issue is it opens with a JavaScript Error 'Error in Site JavaScript) as well as opening very slow ( it appears to be loading all.js when opening the dialog - taking bulk of the time)

does the "JavaScript Error" disappear once the form has opened?

And to be clear - this is a NetTalk app? with a custom JavaScript widget on the page?


cheers
Bruce

valicgordon

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Hi, LOL, Ver 6.28.

The error does not go away after the the form has opened.

Yes, Nettalk app with custom Javascript widget on page.

Thanks

Sylvester

valicgordon

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Bruce, I think the question is how would I call a nettalk form from the custom javascript widget that would have it work exactly the same if called from within nettalk, either from a menu item, browse etc.

Currently I call a form, as per my example,
var tag1 = $("<div></div>");
$.ajax({
url: "BookingForm?sessioncode="+id+"&staffid="+ev.section_id+"&itemid="+ev.section4_id+"&resourceid="+ev.section2_id+"&equipmentid="+ev.section3_id+"&startdate="+ev.start_date+"&enddate="+ev.end_date,
success: function(data) {
tag1.html(data).dialog({modal: true, height: 750, width: 550, close: function(event, ui) { DoCloseEvent(); }    }).dialog('open');         
             } // success funtion
    });  //close this ajax     

To open it as a JQuery dialog.

If you could point me in the right direction, much appreciated.

Thanks

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11244
    • View Profile
The answer is in 2 parts;

a) the div for the form needs to be on the page already. (this is done automatically when the page is generated from NetTalk, and it can "see" that it might need the form).
The div is named in the form;
id="popup_procedurename_div"
this is always in lowercase.

b) To open the form (in javascript) you call ntd.push, like this;

ntd.push('MailboxesBrowseControl','ALI__MailBoxNumber','Mail Box:',1,6,'','AliasFormControl','asdfgh','fred=1&bob=2')

where the parameters are;
1. ProcedureName - ie the name of the wrapper, without the popup_  and _div parts.
2. Name of the lookup field (in the case of a popup being initiated from a lookup button)
3. Title - This appears in the title part of the dialog, if blank the form header is used instead.
4. set to 1 (ie makes the dialog appear now.)
5. action: 1=insert, 2=change, 3=delete, 4=copy, 5=view, 6=lookup
6. Sortfield (likely the empty string if calling a form)
7. CalledFrom: The name of the procedure calling this dialog. An Ajax notification is set to this procedure when the form closes (with _event_=gainfocus). A different notification is also sent if Save or Cancel is pressed.
8. row (the bidv of the of the session value so the form knows which record is being edited.)
9. another other "parameters" (in the name=value&name=value form) that you want to pass.

there are more, but those are the ones used for opening a form.

cheers
Bruce




valicgordon

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Thanks Bruce, I will implement and test.

Appreciated.

Sylvester

valicgordon

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Hi Bruce

So what I did:

1. Add the div to the page

<div id="popup_bookingform_div"></div>

2. call the form

ntd.push('BookingForm','','Update',1,1,'','PageScheduler','','fred=1&bob=2')


I can see the call as a result from the ntd.push, in the Console

http://server/BookingForm?_ajax_=1&pressedButton=change_btn&_popup_=1&_bidv_=899999999&fred=1&bob=2

Nettalk server

debugging, I can see the response is the form I am loading.

GET /BookingForm?_ajax_=1&pressedButton=change_btn&_popup_=1&_bidv_=899999999&fred=1&bob=2 HTTP/1.1
Host: server
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:22.0) Gecko/20100101 Firefox/22.0
Accept: */*
Accept-Language: en-gb,en;q=0.5
Accept-Encoding: gzip, deflate
X-Requested-With: XMLHttpRequest
Referer: http://server/PageScheduler
Connection: keep-alive

the reponse shows me my form, I will post a new line.

The issue is No Popup actually opens, could it be an issue with the initial div, with the popup_procName_div

To confirm, must this div  be on the refer page, in this case, PageScheduler?


Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11244
    • View Profile
did you add the script to make popup_bookingform_div a Dialog?
you still need to do that - ie

$('#popup_bookingform_div').dialog();

in the appropriate place (as a <script> tag, or as a p_web.Script call).

cheers
Bruce

valicgordon

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Thanks for the help Bruce, all sorted and working well.

Sylvester