R
R
Roman Malyshkin2017-04-03 17:30:04
JavaScript
Roman Malyshkin, 2017-04-03 17:30:04

Jquery+Joomla compatibility error; How to decide?

I am writing a module for Joomla. When porting the code, I encountered a compatibility issue:
"TypeError: jQuery(...).tooltip is not a function"
default.php

spoiler

<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
  <select id="list" name="select">
      <option value="0">1 группа</option>
      <option value="1">2 группа</option>
  </select>
  <input id="wall1" type="submit" onclick="post_group()">
    
    <script>
      //var xhr = new XMLHttpRequest();
      //xhr.open('GET', 'test.json', false);
      //xhr.send();
      //if (xhr.status != 200) 
      //{
        //alert( xhr.status + ': ' + xhr.statusText );
      //} else 
      //{
        //alert( xhr.responseText );
      //}
    
    
    
    
    
      //jQuery( document ).ready(function() 
      function clear() 
      {
        document.getElementById('img').innerHTML = '';
      }
      function post_group()
      {
        clear();
        var group = jQuery('#list').val();
        var obj_group;
        jQuery.ajax(
        {
          //r:\home\localhost\www\joomla\modules\module_vk\
          type: "POST",
          url: 'r:/home/localhost/www/joomla/modules/module_vk/group.php',
          dataType: 'json',
          data:{select:group},
          async:false,
          success: function(group)
          {
            obj_group = jQuery.parseJSON(group);
            
          }
        });
        
        jQuery.ajax(
        {
          type: "POST",
          url: "r:/home/localhost/www/joomla/modules/module_vk/test.php",
          dataType: 'json',
          data: {select:group},
          async:false
        })
        .done(function(wall)
        {
          var obj = jQuery.parseJSON(wall);
          console.log(obj);
          for(var i=0;i<50;i++)
          {
            var groups=obj_group.response[0];
            var item = obj.response.items[i]/*.copy_history[0].attachments[0].photo.photo_604*/;
            jQuery('#img').append("<img src='"+groups.photo_50+"'> ");
            jQuery('#img').append("<a href=http://vk.com/"+groups.screen_name+">"+groups.name+"</a></br>");
            if((typeof item.copy_history == 'undefined')&&(typeof item.attachments!='undefined'))
            {
              if(typeof item.text!='')
              {
                jQuery('#img').append("<p style=margin-left:53>"+item.text+"</p>"+"</br>");
                if(typeof item.attachments[0].photo!='undefined')
                {
                  var img = item.attachments[0].photo.photo_604;
                  jQuery('#img').append("<img hspace=50 src='"+img+"'></br>");
                }
              }
              else if(typeof item.attachments[0].photo!='undefined')
              {
                var img = item.attachments[0].photo.photo_604;
                jQuery('#img').append("<img hspace=50 src='"+img+"'></br>");
              }
              /*else if(typeof item.attachments[0].doc!='undefined')
              {
                
                var po=item.attachments[0].doc.url;
                console.log(po);
                $('#img').append("<a href="+po+">Документ</a></br>");
              }*/
            }
            else if((typeof item.attachments == 'undefined')&&(typeof item.copy_history!='undefined'))
            {
              if(typeof item.text!='')
              {
                jQuery('#img').append("<p style=margin-left:53>"+item.text+"</p>"+"</br>");
              }
              var img = item.copy_history[0].attachments[0].photo.photo_604;
              jQuery('#img').append("<img hspace=50 src='"+img+"'></br>");
            }
            else
            {
              jQuery('#img').append("<p style=margin-left:53>"+item.text+"</p>"+"</br>");
            }
          }

          jQuery("#msg").html(result);
        });
      }
</script>

    <div id="img"></div>


group.php
spoiler
<?php
  $group_0=53607891;
  $group_1=63232814;
  $iop=$_POST['select'];
  //echo $iop;
  if ($iop==0)
  {
    $group_id=$group_0;
  }
  else if($iop==1)
  {
    $group_id=$group_1;
  }
  $group = file_get_contents("http://api.vk.com/method/groups.getById?group_id={$group_id}&v=5.52");
  echo json_encode($group,true);
?>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Goryachev, 2017-04-03
@webirus

www.joomla-study.ru/komponenty/otkliuchenie-freimv...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question