1
이것은 this topic의 두 번째 부분과 같으며 지금은 동적 인 data-*
속성을 선택해야합니다. 이게 무슨 뜻이야? 당신이보고있는 것은 다음과 같은 코드가 무엇을select2에서 선택한 옵션의 data- * 값을 얻는 방법은 무엇입니까?
입니다 : 다음 이미지를 살펴 걸릴
먼저
// This turn 1st and 3rd into select2
$('#module, #conditions').select2();
// This turn 2nd into select2 using data from a datasource
$('select#fields').select2({
placeholder: 'Select a field',
data: data.fields
});
내가 참조 항목에 게시 된을 data.fields
에는 다음과 같은 JSON이 있습니다.
"fields": [
{
"id": "companies_id",
"text": "companies_id",
"data-type": "int"
},
{
"id": "parent_companies_id",
"text": "parent_companies_id",
"data-type": "int"
},
{
"id": "client_of_companies_id",
"text": "client_of_companies_id",
"data-type": "int"
},
{
"id": "asset_locations_id",
"text": "asset_locations_id",
"data-type": "int"
},
{
"id": "companies_name",
"text": "companies_name",
"data-type": "varchar"
},
{
"id": "companies_number",
"text": "companies_number",
"data-type": "varchar"
}
]
이 경우에는 onChange()
이벤트에서 세 번째 선택 (조건)의 두 번째 선택 (필드)에 할당 된 data-*
속성을 읽고 INPUT을 수정해야합니다 (그러나 이것은 나에게 적용됩니다).
다른 select2 요소에서 data-*
값을 얻으려면 어떻게해야합니까?
! lol thx 정확히 내가 필요한 ... – ReynierPM
안녕하세요 @Dekel 당신이 [이]와 함께 나를 도울 수 있습니까 (http://stackoverflow.com/questions/40386965/can-not-trigger-an-ajax-call-into-element- turn-in-a-select2)와 [this] (http://stackoverflow.com/questions/40388162/cant-make-select2-work-when-element-is-inside-a-jquery-ui-modal) as 잘? 나는 그들에 붙어있어 내가 뭘 잘못하고 어쩌면 문제가 같은지 모르겠다 – ReynierPM
내가 좀 해보려고 노력할거야. – Dekel