cagliostro
asked 5 years ago

Hello.

When someone tries to post a new question, during the Title post, he gets some suggestions about already posted similar questions. This creates a havoc in the page and the suggestions include all kind of links.

This is visually and in general unwanted. How can i turn this ajax off ?

Thanks

1 Answers
DominicStaff
answered 5 years ago

If you want to turn off the ajax auto-suggestion the title question in the submit question form, you can open the wp-content -> plugins -> dw-question-answer -> templates -> assets -> js -> dwqa-submit-question.js and replace all the code lines in this file with the following code:

// (function($){
//  $('#question-title').autocomplete({
//      appendTo: '.dwqa-search',
//      source: function( request, resp ) {
//          $.ajax({
//              url: dwqa.ajax_url,
//              type: 'POST',
//              dataType: 'json',
//              data: {
//                  action: 'dwqa-auto-suggest-search-result',
//                  title: request.term,
//                  nonce: $('#question-title').data('nonce')
//              },
//              success: function( data ) {
//                  console.log( data );
//                  resp( $.map( data.data, function( item ) {
//                      if ( true == data.success ) {
//                          return {
//                              label: item.title,
//                              value: item.title,
//                              url: item.url,
//                          }
//                      }
//                  }))
//              }
//          });
//      },
//      select: function( e, ui ) {
//          keycode = e.which || e.keyCode;

//          if ( keycode == 13 ) {
//              return true;
//          } else {
//              if ( ui.item.url ) {
//                  window.open( ui.item.url );
//              }
//          }
//      },
//      open: function( e, ui ) {
//          var acData = $(this).data( 'uiAutocomplete' );
//          acData.menu.element.addClass('dwqa-autocomplete').find('li').each(function(){
//              var $self = $(this),
//                  keyword = $.trim( acData.term ).split(' ').join('|');
//                  $self.html( $self.text().replace( new RegExp( "(" + keyword + ")", "gi" ), '<span class="dwqa-text-highlight">$1</span>' ) );
//          });
//      }
//  })
// })(jQuery);

Hope this helps!

cagliostro
replied 5 years ago

Thanks, works well now.

Powered by DW Question & Answer Pro