2017-12-19 26 views
-1

계단식 다중 선택 드롭 다운에 재사용 가능한 자바 스크립트 코드를 사용하고 있습니다. 사용법 중 하나에 대해서는 완벽하게 작동하지만 동일한 코드를 사용하는 다른 위치에서는 그렇지 않습니다. 그것이 작동하지 않는 이유는 어떻게됩니까 내가 제품에 따라 선택받을 기관 (IATAs), 채널에 할당 된 문서 (작동하지 않는 점)과 UploadProfiles (workikng 지점)을 만드는 것이,하고 enter image description here한 위치에서 Symfony Javascript 드롭 다운이 올바르게 작동하지만 다른 곳에서는 올바르게 작동하지 않습니다.

을 판매 :

  1. 배열 컬렉션으로 채널 및 제품을 내 문서 엔티티 생성자에 추가하면 제출 후 내 문서가 모든 채널 또는 제품에 할당되지 않습니다. 내 양식을 생성자에서 그들을 제거하고 제출
  2. , 나는 다음과 같은 오류 메시지가 배열의 멤버 함수 removeElement에

전화() 얻을

나는에 복사합니다

내 엔티티와 자바 스크립트 코드. 필요한 것이 있으면 알려주세요. 내가 어디에서봤을 지 모르겠다. (1) 동일한 코드 모두에 : 나는 1 이후 오류가있는 것을 믿을 수 없다하더라도

문서 엔티티

<?php 

namespace DocumentBundle\Entity; 

use AppBundle\Entity\FileAwareEntity; 
use Doctrine\ORM\Mapping as ORM; 
use Doctrine\Bundle\DoctrineBundle\Registry; 
use Doctrine\Common\Collections\ArrayCollection; 
use FS\SolrBundle\Doctrine\Annotation as Solr; 
use Symfony\Component\Validator\Constraints as Assert; 
use Symfony\Component\Validator\ExecutionContextInterface; 
use Symfony\Component\HttpFoundation\File\UploadedFile; 
use Symfony\Component\DependencyInjection\ContainerInterface; 
use Symfony\Component\Security\Core\Security; 
use UserBundle\Entity\User as User; 


/** 
* @ORM\HasLifecycleCallbacks() 
* @ORM\Table(name="document_document", options={"engine"="InnoDB"}) 
* @ORM\Entity(repositoryClass="DocumentBundle\Entity\DocumentRepository") 
*/ 
class Document extends FileAwareEntity { 
    /** 
    * @ORM\Column(type="integer") 
    * @Solr\Id 
    * @ORM\Id 
    * @ORM\GeneratedValue(strategy="AUTO") 
    */ 
    private $id; 

    /** 
    * @Solr\Field(type="string") 
    * @Assert\NotBlank() 
    * @var string 
    * @ORM\Column(type="string") 
    */ 
    private $name; 

    /** 
    * @ORM\ManyToMany(targetEntity="AppBundle\Entity\Agency", inversedBy="documentagencies", cascade={"persist"}) 
    * @ORM\JoinTable(name="document_document_agencies", 
    * joinColumns={@ORM\JoinColumn(name="document_id", referencedColumnName="id")}, 
    * inverseJoinColumns={@ORM\JoinColumn(name="iata8", referencedColumnName="iata8")}) 
    * @var \AppBundle\Entity\Agency 
    **/ 
    private $agencies; 

    /** 
    * @ORM\ManyToMany(targetEntity="AppBundle\Entity\Market", inversedBy="documents", cascade={"persist"}) 
    * @ORM\JoinTable(name="document_document_markets", 
    * joinColumns={@ORM\JoinColumn(name="document_id", referencedColumnName="id")}, 
    * inverseJoinColumns={@ORM\JoinColumn(name="market_id", referencedColumnName="id")}) 
    * @Assert\Count(
    *  min = "0" 
    *) 
    **/ 
    private $markets; 

    /** 
    * @ORM\ManyToMany(targetEntity="AppBundle\Entity\Airline", inversedBy="documents", cascade={"persist"}) 
    * @ORM\JoinTable(name="document_document_airlines", 
    * joinColumns={@ORM\JoinColumn(name="document_id", referencedColumnName="id")}, 
    * inverseJoinColumns={@ORM\JoinColumn(name="airline_id", referencedColumnName="id")}) 
    * @Assert\Count(
    *  min = "0" 
    *) 
    * @var \AppBundle\Entity\Airline 
    **/ 
    private $airlines; 

    /** 
    * @ORM\ManyToMany(targetEntity="AppBundle\Entity\Product", inversedBy="documents", cascade={"persist"}) 
    * @ORM\JoinTable(name="document_document_products", 
    * joinColumns={@ORM\JoinColumn(name="document_id", referencedColumnName="id")}, 
    * inverseJoinColumns={@ORM\JoinColumn(name="product_id", referencedColumnName="id")}) 
    * @Assert\Count(
    *  min = "0" 
    *) 
    * @var \AppBundle\Entity\Product 
    **/ 
    private $products; 

    /** 
    * @ORM\ManyToMany(targetEntity="ReferentialBundle\Entity\Channel1", inversedBy="documents", cascade={"persist"}) 
    * @ORM\JoinTable(name="document_document_channel1", 
    * joinColumns={@ORM\JoinColumn(name="document_id", referencedColumnName="id")}, 
    * inverseJoinColumns={@ORM\JoinColumn(name="channel1_id", referencedColumnName="id")}) 
    * @Assert\Count(
    *  min = "0" 
    *) 
    * @var \ReferentialBundle\Entity\Channel1 
    **/ 

    private $channel1; 

    /** 
    * Constructor 
    */ 
    public function __construct() 
    { 
     $this->locked = false; 
     $this->signed = false; 
     $this->markets = new \Doctrine\Common\Collections\ArrayCollection(); 
     $this->agencies = new \Doctrine\Common\Collections\ArrayCollection(); 
     // $this->channel1 = new \Doctrine\Common\Collections\ArrayCollection(); 
     // $this->products = new \Doctrine\Common\Collections\ArrayCollection(); 
     // $this->airlines = new \Doctrine\Common\Collections\ArrayCollection(); 
    } 

    /** 
    * Get id 
    * 
    * @return integer 
    */ 
    public function getId() 
    { 
     return $this->id; 
    } 

    function setId($id) { 
     $this->id = $id; 
    } 

    /** 
    * Set name 
    * 
    * @param string $name 
    * @return Document 
    */ 
    public function setName($name) 
    { 
     $this->name = $name; 

     return $this; 
    } 

    /** 
    * Get name 
    * 
    * @return string 
    */ 
    public function getName() 
    { 
     return $this->name; 
    } 

    /** 
    * Add agency 
    * 
    * @param \AppBundle\Entity\Agency $agency 
    * 
    * @return Document 
    */ 
    public function addAgency(\AppBundle\Entity\Agency $agency) 
    { 
     $this->agencies[] = $agency; 

     return $this; 
    } 

    /** 
    * Remove agency 
    * 
    * @param \AppBundle\Entity\Agency $agency 
    */ 
    public function removeAgency(\AppBundle\Entity\Agency $agency) 
    { 
     $this->agencies->removeElement($agency); 
    } 

    /** 
    * Get agencies 
    * 
    * @return \Doctrine\Common\Collections\Collection 
    */ 
    public function getAgencies() 
    { 
     return $this->agencies; 
    } 

    /** 
    * Add market 
    * 
    * @param \AppBundle\Entity\Market $market 
    * 
    * @return Document 
    */ 
    public function addMarket(\AppBundle\Entity\Market $market) 
    { 
     $this->markets[] = $market; 

     return $this; 
    } 

    /** 
    * Remove market 
    * 
    * @param \AppBundle\Entity\Market $market 
    */ 
    public function removeMarket(\AppBundle\Entity\Market $market) 
    { 
     $this->markets->removeElement($market); 
    } 

    /** 
    * Get markets 
    * 
    * @return \Doctrine\Common\Collections\Collection 
    */ 
    public function getMarkets() 
    { 
     return $this->markets; 
    } 

    /** 
    * Add airline 
    * 
    * @param \AppBundle\Entity\Airline $airline 
    * 
    * @return Document 
    */ 
    public function addAirline(\AppBundle\Entity\Airline $airline) 
    { 
     $this->airlines[] = $airline; 

     return $this; 
    } 

    /** 
    * Remove airline 
    * 
    * @param \AppBundle\Entity\Airline $airline 
    */ 
    public function removeAirline(\AppBundle\Entity\Airline $airline) 
    { 
     $this->airlines->removeElement($airline); 
    } 

    /** 
    * Get airlines 
    * 
    * @return \Doctrine\Common\Collections\Collection 
    */ 
    public function getAirlines() 
    { 
     return $this->airlines; 
    } 

    /** 
    * Add product 
    * 
    * @param \AppBundle\Entity\Product $product 
    * 
    * @return Document 
    */ 
    public function addProduct(\AppBundle\Entity\Product $product) 
    { 
     $this->products[] = $product; 

     return $this; 
    } 

    /** 
    * Remove product 
    * 
    * @param \AppBundle\Entity\Product $product 
    */ 
    public function removeProduct(\AppBundle\Entity\Product $product) 
    { 
     $this->products->removeElement($product); 
    } 

    /** 
    * Get products 
    * 
    * @return \Doctrine\Common\Collections\Collection 
    */ 
    public function getProducts() 
    { 
     return $this->products; 
    } 

    /** 
    * Add channel1 
    * 
    * @param \ReferentialBundle\Entity\Channel1 $channel1 
    * 
    * @return Document 
    */ 
    public function addChannel1(\ReferentialBundle\Entity\Channel1 $channel1) 
    { 
     $this->channel1[] = $channel1; 

     return $this; 
    } 

    /** 
    * Remove channel1 
    * 
    * @param \ReferentialBundle\Entity\Channel1 $channel1 
    */ 
    public function removeChannel1(\ReferentialBundle\Entity\Channel1 $channel1) 
    { 
     $this->channel1->removeElement($channel1); 
    } 

    /** 
    * Get channel1 
    * 
    * @return \Doctrine\Common\Collections\Collection 
    */ 
    public function getChannel1() 
    { 
     return $this->channel1; 
    }  
} 

업로드 프로필 법인

<?php 

namespace DocumentBundle\Entity; 

use Doctrine\ORM\Mapping as ORM; 
use Symfony\Component\Validator\Constraints as Assert; 
use Doctrine\Common\Collections\ArrayCollection; 
use AppBundle\Entity\Airline; 
use Doctrine\ORM\Event\PreFlushEventArgs; 
use Doctrine\ORM\Event\LifeCycleEventArgs; 

/** 
* @ORM\Entity 
* @ORM\HasLifecycleCallbacks() 
* @ORM\Entity(repositoryClass="DocumentBundle\Entity\UploadProfileRepository") 
* @ORM\Table(name="document_uploadprofile", options={"engine"="InnoDB"}) 
*/ 
class UploadProfile{ 
    /** 
    * @ORM\Column(type="integer") 
    * @ORM\Id 
    * @ORM\GeneratedValue(strategy="AUTO") 
    */ 
    private $id; 

    /** 
    * @ORM\Column(type="string", length=100) 
    */ 
    private $name; 
    /** 
    * @ORM\ManyToMany(targetEntity="AppBundle\Entity\Market", inversedBy="uploadProfiles", cascade={"persist"}) 
    * @ORM\JoinTable(name="document_uploadprofile_markets", 
    * joinColumns={@ORM\JoinColumn(name="uploadprofile_id", referencedColumnName="id")}, 
    * inverseJoinColumns={@ORM\JoinColumn(name="market_id", referencedColumnName="id")}) 
    **/ 
    private $markets; 

    /** 
    * @ORM\ManyToMany(targetEntity="AppBundle\Entity\Agency", inversedBy="uploadProfiles", cascade={"persist"}) 
    * @ORM\JoinTable(name="document_uploadprofile_agencies", 
    * joinColumns={@ORM\JoinColumn(name="uploadprofile_id", referencedColumnName="id")}, 
    * inverseJoinColumns={@ORM\JoinColumn(name="iata8", referencedColumnName="iata8")}) 
    **/ 
    private $agencies; 

    /** 
    * @ORM\ManyToMany(targetEntity="AppBundle\Entity\Airline", inversedBy="uploadProfiles", cascade={"persist"}) 
    * @ORM\JoinTable(name="document_uploadprofile_airlines", 
    * joinColumns={@ORM\JoinColumn(name="uploadprofile_id", referencedColumnName="id")}, 
    * inverseJoinColumns={@ORM\JoinColumn(name="airline_id", referencedColumnName="id")}) 
    * @var \AppBundle\Entity\Airline 
    **/ 

    private $airlines; 


    /** 
    * @ORM\ManyToMany(targetEntity="ReferentialBundle\Entity\Channel1", inversedBy="uploadProfiles", cascade={"persist"}) 
    * @ORM\JoinTable(name="document_uploadprofile_channel1", 
    * joinColumns={@ORM\JoinColumn(name="uploadprofile_id", referencedColumnName="id")}, 
    * inverseJoinColumns={@ORM\JoinColumn(name="channel1_id", referencedColumnName="id")}) 
    * @var \ReferentialBundle\Entity\Channel1 
    **/ 
    private $channel1; 
    /** 
    * @ORM\ManyToMany(targetEntity="AppBundle\Entity\Product", inversedBy="uploadProfiles", cascade={"persist"}) 
    * @ORM\JoinTable(name="document_uploadprofile_products", 
    * joinColumns={@ORM\JoinColumn(name="uploadprofile_id", referencedColumnName="id")}, 
    * inverseJoinColumns={@ORM\JoinColumn(name="product_id", referencedColumnName="id")}) 
    * @Assert\Count(
    *  min = "1" 
    *) 
    * @var \AppBundle\Entity\Product 
    **/ 
    private $products; 

    /** 
    * Constructor 
    */ 
    public function __construct() 
    { 
     $this->agencies = new \Doctrine\Common\Collections\ArrayCollection(); 
     $this->markets = new \Doctrine\Common\Collections\ArrayCollection(); 
      // $this->channel1s = new \Doctrine\Common\Collections\ArrayCollection(); 
      // $this->channel3s = new \Doctrine\Common\Collections\ArrayCollection(); 
     $this->locked = false; 
     $this->archived = false; 
    } 

    /** 
    * Get id 
    * 
    * @return integer 
    */ 
    public function getId() 
    { 
     return $this->id; 
    } 

    function setId($id) { 
     $this->id = $id; 
    } 

    /** 
    * Get name 
    * 
    * @return string 
    */ 
    public function getName() 
    { 
     return $this->name; 
    } 
    /** 
    * Set name 
    * 
    * @param string $name 
    * @return UploadProfile 
    */ 
    public function setName($name) 
    { 
     $this->name = $name; 

     return $this; 
    } 


    /** 
    * Add market 
    * 
    * @param \AppBundle\Entity\Market $market 
    * 
    * @return UploadProfile 
    */ 
    public function addMarket(\AppBundle\Entity\Market $market) 
    { 
     $this->markets[] = $market; 

     return $this; 
    } 

    /** 
    * Remove market 
    * 
    * @param \AppBundle\Entity\Market $market 
    */ 
    public function removeMarket(\AppBundle\Entity\Market $market) 
    { 
     $this->markets->removeElement($market); 
    } 

    /** 
    * Get markets 
    * 
    * @return \Doctrine\Common\Collections\Collection 
    */ 
    public function getMarkets() 
    { 
     return $this->markets; 
    } 

    /** 
    * Add agency 
    * 
    * @param \AppBundle\Entity\Agency $agency 
    * 
    * @return UploadProfile 
    */ 
    public function addAgency(\AppBundle\Entity\Agency $agency) 
    { 
     $this->agencies[] = $agency; 

     return $this; 
    } 

    /** 
    * Remove agency 
    * 
    * @param \AppBundle\Entity\Agency $agency 
    */ 
    public function removeAgency(\AppBundle\Entity\Agency $agency) 
    { 
     $this->agencies->removeElement($agency); 
    } 

    /** 
    * Get agencies 
    * 
    * @return \Doctrine\Common\Collections\Collection 
    */ 
    public function getAgencies() 
    { 
     return $this->agencies; 
    } 

    /** 
    * Add airline 
    * 
    * @param \AppBundle\Entity\Airline $airline 
    * 
    * @return UploadProfile 
    */ 
    public function addAirline(\AppBundle\Entity\Airline $airline) 
    { 
     $this->airlines[] = $airline; 

     return $this; 
    } 

    /** 
    * Remove airline 
    * 
    * @param \AppBundle\Entity\Airline $airline 
    */ 
    public function removeAirline(\AppBundle\Entity\Airline $airline) 
    { 
     $this->airlines->removeElement($airline); 
    } 

    /** 
    * Get airlines 
    * 
    * @return \Doctrine\Common\Collections\Collection 
    */ 
    public function getAirlines() 
    { 
     return $this->airlines; 
    } 

    /** 
    * Add channel1 
    * 
    * @param \ReferentialBundle\Entity\Channel1 $channel1 
    * 
    * @return UploadProfile 
    */ 
    public function addChannel1(\ReferentialBundle\Entity\Channel1 $channel1) 
    { 
     $this->channel1[] = $channel1; 

     return $this; 
    } 

    /** 
    * Remove channel1 
    * 
    * @param \ReferentialBundle\Entity\Channel1 $channel1 
    */ 
    public function removeChannel1(\ReferentialBundle\Entity\Channel1 $channel1) 
    { 
     $this->channel1->removeElement($channel1); 
    } 

    /** 
    * Get channel1 
    * 
    * @return \Doctrine\Common\Collections\Collection 
    */ 
    public function getChannel1() 
    { 
     return $this->channel1; 
    } 

    /** 
    * Add product 
    * 
    * @param \AppBundle\Entity\Product $product 
    * 
    * @return UploadProfile 
    */ 
    public function addProduct(\AppBundle\Entity\Product $product) 
    { 
     $this->products[] = $product; 

     return $this; 
    } 

    /** 
    * Remove product 
    * 
    * @param \AppBundle\Entity\Product $product 
    */ 
    public function removeProduct(\AppBundle\Entity\Product $product) 
    { 
     $this->products->removeElement($product); 
    } 

    /** 
    * Get products 
    * 
    * @return \Doctrine\Common\Collections\Collection 
    */ 
    public function getProducts() 
    { 
     return $this->products; 
    } 
} 

내 자바 스크립트 함수 (

<script type="text/javascript"> 

var message = false; 

// Form dropdown disabling 
$(document).ready(function(){ 

    // disable channel, product, agency 
    init_MCPA_DDs(); 
    document.getElementById("___before-submit___").disabled = true; 

}); 

$('#helpModal').on('show.bs.modal', function (event) { 
    var button = $(event.relatedTarget) // Button that triggered the modal 
    header = button.data('header') // Extract info from data-* attributes 
    text = button.data('text') 
    var modal = $(this) 
    modal.find('.modal-title').text(header) 
    modal.find('.modal-body').text(text) 
}); 

// Market->Channel1->Product->Agency Selection 

function init_MCPA_DDs() 
{ 
    $('#{{ form.vars.name }}_channel1').multiselect('disable'); 
    $('#{{ form.vars.name }}_products').multiselect('disable'); 
    $('#{{ form.vars.name }}_agencies').multiselect('disable'); 
    // 
    $('#{{ form.vars.name }}_markets').on("change",function() { 
    if($(this).val() != null) { 
     $('#{{ form.vars.name }}_channel1').multiselect('enable'); 
    } 
    }); 
} 

function refresh_all_ms() 
{ 
    // BS MS SA Fix 
    $('#{{ form.vars.name }}_markets').multiselect('refresh'); 
    $('#{{ form.vars.name }}_channel1').multiselect('refresh'); 
    $('#{{ form.vars.name }}_products').multiselect('refresh'); 
    $('#{{ form.vars.name }}_agencies').multiselect('refresh'); 
} 

function reset_P() 
{ 
    $('#{{ form.vars.name }}_products').empty(); 
    $('#{{ form.vars.name }}_products').multiselect('rebuild'); 
    $('#{{ form.vars.name }}_products').multiselect('disable'); 
} 

function reset_A() 
{ 
    $('#{{ form.vars.name }}_agencies').empty(); 
    $('#{{ form.vars.name }}_agencies').multiselect('rebuild'); 
    $('#{{ form.vars.name }}_agencies').multiselect('disable'); 
    document.getElementById("___before-submit___").disabled = true; 
} 

function reset_PA() 
{ 
    reset_P(); 
    reset_A(); 
} 

var market_data = new String('___'); 
var channel1_data = new String('____'); 
var product_data = new String('____'); 
makeMultiselectDropdown('#{{ form.vars.name }}_airlines', 'Select Airlines'); 

makeMultiselectDropdown('#{{ form.vars.name }}_markets', 'Select Markets', { 
    onDropdownShown: function(event) { 
    market_data = $('#{{ form.vars.name }}_markets').val(); 
    if (market_data == null) { market_data = '___'; } 
    }, 
    onDropdownHide: function(event) { 
    var md = $('#{{ form.vars.name }}_markets').val(); 
    if (md == null) { 
     md = '____'; 
     reset_PA(); 
    } 
    if (market_data.toString().localeCompare(md)) { 
     reset_PA(); 
     handleMarketChannelChoice(true); 
    } 
    refresh_all_ms(); 
    } 
}); 

makeMultiselectDropdown('#{{ form.vars.name }}_channel1', 'Select Channel', { 
    onDropdownShown: function(event) { 
    channel1_data = $('#{{ form.vars.name }}_channel1').val(); 
    if (channel1_data == null) { channel1_data = '____'; } 
    }, 
    onDropdownHide: function(event) { 
    var cd = $('#{{ form.vars.name }}_channel1').val(); 
    if (cd == null) { 
     cd = '____'; 
     reset_PA(); 
    } 
    if (channel1_data.toString().localeCompare(cd)) { 
     reset_PA(); 
     handleMarketChannelChoice(true); 
    } 
    refresh_all_ms(); 
    } 
}); 

makeMultiselectDropdown('#{{ form.vars.name }}_products', 'Select Products', { 
    onDropdownShown: function(event) { 
     product_data = $('#{{ form.vars.name }}_products').val(); 
     if (product_data == null) { product_data = '___'; } 
    }, 
    onDropdownHide: function(event) { 
    var pd = $('#{{ form.vars.name }}_products').val(); 
    if (pd == null) { 
     pd = '____'; 
     reset_A(); 
    } 
    if (product_data.toString().localeCompare(pd)) { 
     reset_A(); 
     handleProductChoice(true); 
    } 
    refresh_all_ms(); 
    } 
}); 

makeMultiselectDropdown('#{{ form.vars.name }}_agencies', 'Select Agencies', { 
    onDropdownHide: function(event) { 
    refresh_all_ms(); 
    }, 
    onDropdownHide: function(event) { 
    var ad = $('#{{ form.vars.name }}_agencies').val(); 
    if (ad !== null && ad !=='text') { 
     document.getElementById("___before-submit___").disabled = false; 
    } 

    } 
}); 

//Populate Product dropdown 
function handleMarketChannelChoice() { 

    var channel1 = $('#{{ form.vars.name }}_channel1').val(); 
    var market = $('#{{ form.vars.name }}_markets').val(); 

    if (market === null || channel1 === null) return false; 

    path = "{{ path('documentBundle_marketChannelData') }}"; 

    $.get(path, 
     {market: market, channel1: channel1}, 
     function(response) { 
      response = JSON.parse(response); 
      if(response.code == '100' && response.success) { 
       $('#{{ form.vars.name }}_products').empty(); 
       for (var i=0; i<response.productName.length; i++) { 
        $('#{{ form.vars.name }}_products').append($('<option>', { 
              value: response.productId[i], 
               text: response.productName[i] 
              })); 
       } 
       $('#{{ form.vars.name }}_products').multiselect('rebuild'); 
       $('#{{ form.vars.name }}_products').multiselect('enable'); 

      } else { 
       alert('No Products found for selected Market, Channel'); 
      } 
     } 
    ); 
} 

//Populate Agency Dropdown 
function handleProductChoice() { 

    var product = $('#{{ form.vars.name }}_products').val(); 
    if (product === null) return false; 
    path = "{{ path('documentBundle_productData') }}"; 

    $.get(path, 
     {product: product,}, 
     function(response) { 
      response = JSON.parse(response); 
      if(response.code == '100' && response.success) { 
       $('#{{ form.vars.name }}_agencies').empty(); 
       for (var i=0; i<response.agencyId.length; i++){ 
        $('#{{ form.vars.name }}_agencies').append($('<option>', { 
             value: response.agencyId[i], 
              text: response.agencyName[i] 
             })); 
       } 

       $('#{{ form.vars.name }}_agencies').multiselect('rebuild'); 
       $('#{{ form.vars.name }}_agencies').multiselect('enable'); 
      } else { 
       alert('No Agencies found for selected Market, Channel, Product'); 
      } 
     } 
    ); 
} 

</script> 

업로드 프로필의 경우 자바 스크립트 및 양식 유형이 동일한 나뭇 가지 템플릿에 포함되어 있습니다. 다른 자바 스크립트에 액세스하지 않았습니다. 문서의 경우 약간 더 복잡합니다 :

다른 twig 템플릿에있는 문서 작성을위한 양식 유형을 포함하여 create-twig-template이 있습니다. create-twig-template과 form-twig-template 모두 javascript 파일과 두 개의 추가 javascript 파일을 포함합니다. 이 정보가 필요한지 나는 알지 못합니다. 단지 상황을 알려주려고 생각했습니다.

미리 감사드립니다.

답변

0

SPA가 아닌 경우 ID가 동일하다는 것을 의미합니다 (Copypaste 냄새). ID와 1 : 1이 일치하지 않는지 확인하십시오.

 onDropdownHide: function(event) { 
     var ad = $('#{{ form.vars.name }}_agencies').val(); 
     if (ad !== null && ad !=='text') { 
/// make sure you the id doesn't already exist on the html page. ___before-submit___ 
      document.getElementById("___before-submit___").disabled = false; 
     } 

     } 

또한 jQuery가 실제로 요소에 바인딩되어 있고 기능을 실행하고 있는지 확인하십시오.

+0

SPA 란 무엇이며 어떤 ID에 대해 이야기하고 있습니까? 서로 다른 양식 유형이므로 함수가 모두 고유하므로 고유 한 방법입니다. – sonja

+0

id global 속성은 전체 문서에서 고유해야하는 고유 식별자 (ID)를 정의합니다. 그 목적은 링크 (조각 식별자 사용), 스크립팅 또는 스타일 지정 (CSS 사용)시 요소를 식별하는 것입니다. [link] (https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id) – jriver27

+0

ID가 무엇인지 알지만 내 ID는 모두 고유합니다.난 그냥 내 대답을 해결하는 데 도움이되는 방법을 이해하지 못합니다 내 기능이 제대로 발사됩니다. 드롭 다운 자체가 올바른 데이터로 작업하기를 원하는 방식으로 작동합니다. – sonja