Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

170
Views
formulario de botón para encabezado pegajoso por javascript html laravel

Hay dos botones en esas hojas (Laravel). El botón ( .btn-main ) funciona en el main , pero el botón ( .btn-header ) en el encabezado no funciona.

Quiero decir, cuando hago clic en el botón ( .btn-header ) en el encabezado , no hace nada y no se guarda en la base de datos.

Sé que se trata de la forma .

inc/header.blade.php

 <div class="sticky fixed"> <button type="submit" class="btn-header">Save</button> </div>

índice.blade.php

 @extends('layouts.app') @section('content') <main> <form action="{{ route('post.update', $post->id) }}" method="POST"> @method('PUT') @csrf <input type="text" name="title" value="Title..."> <input type="text" name="content" value="This is a test."> <button type="submit" class="btn-main">Save</button> </form> </div> @endsection

aplicación.blade.php

 <!DOCTYPE html> <html> <head>...</head> <body> <header> @include('inc.header') </header> @yield('content') </body> </html>

Quiero que los botones funcionen en ambas secciones ( encabezado y principal ) y almacene la información en la base de datos.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Su botón de encabezado no hace nada porque no es parte de/dentro del formulario. Sin embargo, puede usar un atributo de formulario para que funcione su botón de encabezado. Agregue un atributo de id a su elemento <form> y apunte el atributo de form en su botón a esa misma id .

Su formulario:

 @extends('layouts.app') @section('content') <main> <form action="{{ route('post.update', $post->id) }}" method="POST" id="myForm"> @method('PUT') @csrf <input type="text" name="title" value="Title..."> <input type="text" name="content" value="This is a test."> <button type="submit" class="btn-main">Save</button> </form> </div> @endsection

(Se agregó id="myForm" al elemento <form> ).

Su botón de encabezado:

 <div class="sticky fixed"> <button type="submit" class="btn-header" form="myForm">Save</button> </div>

(Se agregó form="myForm" al botón).

Editar: asegúrese de que no haya otro id="myForm" en su página, elija un nombre único diferente si es así

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!