How to access a javascript function that is on another php page?

0

Basically explaining, I have an HTML page that was generated inside a Controller (from Laravel), and in that HTML page has a button that should open a function (to open a SideNav) that is in a view. I can not call this function, what should I do?

Page that is in MapController :

<html>
<head>
  <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
  <link type="text/css" rel="stylesheet" href="css/materialize.min.css" media="screen,projection" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <script type="text/javascript" src="https://code.jquery.com/jquery-3.2.1.min.js"></script><scripttype="text/javascript" src="js/materialize.min.js"></script>
</head>
<body>
  <div class="col s12 m7" style="width:600px;">
    <div class="orange-text">
      <h3 class="header center">'.$empreendimento->nomeFantasia.'</h3>
    </div>
    <div class="card horizontal">
      <div class="card-image" style="width:200px;height:200px;">
        <img src="'.asset('/images/empreendimentos').'/'.$empreendimento->EmpImage.'">
      </div>
      <div class="card-stacked">
        <div class="card-content">
          <label>Ramo Atividade</label>
          <p>'.$ramoAtividade[0]->name.'</p>
          </br>
          <label>Endereço</label>
          <p>'.$empreendimento->endereco.', '.$empreendimento->cidade.', '.$empreendimento->estado.', '.$empreendimento->cep.'</p>
        </div>
        <div class="card-action">
          <a href="#" data-activates="slide-out" class="button-collapse">Veja as ofertas!</a>
        </div>
      </div>
    </div>
  </div>
</body>  
</html>

Where and should the function be enabled in gps.blade.php :

<div>
  {!!Mapper::render()!!}
</div>
<ul id="slide-out" class="side-nav">
  <li>
    <div class="user-view">
      <div class="background">
        <img src="images/office.jpg">
      </div>
      <a href="#!user"><img class="circle" src="images/yuna.jpg"></a>
      <a href="#!name"><span class="white-text name">John Doe</span></a>
      <a href="#!email"><span class="white-text email">[email protected]</span></a>
    </div>
  </li>
  <li><a href="#!"><i class="material-icons">cloud</i>First Link With Icon</a></li>
  <li><a href="#!">Second Link</a></li>
  <li><div class="divider"></div></li>
  <li><a class="subheader">Subheader</a></li>
  <li><a class="waves-effect" href="#!">Third Link With Waves</a></li>
</ul>
<script>
  $(".button-collapse").sideNav({
    menuWidth: 300,
    edge: "left",
    closeOnClick: true,
    draggable: true,
  });
</script>

Page result that is generated in MapController :

    
asked by anonymous 21.11.2017 / 01:57

1 answer

0

You can only call functions that have been loaded into your browser. Maybe you should render the second view along with the main view .. Using some "Partial View" method. Home Or put the javascript code in the first file ... since it does assign the function to ".button-collapse", which is in the first file ..

    
21.11.2017 / 10:24