I have a dynamic list showing collapsible set. It will generate different sets with id="selection_product_info_xxxx" xxxx=dynamic product id.
<div data-role="navbar">
<ul>
<li><a href="#" id="expand_product_info_810" data-theme="c" class="ui-btn-active"><font class="tab_font02">Product 810 Info</font></a></li>
<li><a href="#" id="expand_product_info2_810" data-theme="c" ><font class="tab_font02">Product 810 Info 2</font></a></li>
</ul>
</div>
<!-- Tab End -->
<div data-role="collapsible-set">
<!-- Tab01 Start -->
<div data-role="collapsible" id="selection_product_info_810" data-collapsed="false">
<h3 class="display-none">product 810 info</h3>
<div>Test</div>
</div>
<!-- Tab01 End -->
<!-- Tab02 Start -->
<div data-role="collapsible" id="selection_product_info2_810">
<h3 class="display-none">product 810 info 2</h3>
<div>text 2</div>
</div>
<!-- Tab02 End -->
</div>
<div data-role="navbar">
<ul>
<li><a href="#" id="expand_product_info_820" data-theme="c" class="ui-btn-active"><font class="tab_font02">Product 820 Info</font></a></li>
<li><a href="#" id="expand_product_info2_820" data-theme="c" ><font class="tab_font02">Product 820 Info 2</font></a></li>
</ul>
</div>
<!-- Tab End -->
<div data-role="collapsible-set">
<!-- Tab01 Start -->
<div data-role="collapsible" id="selection_product_info_820" data-collapsed="false">
<h3 class="display-none">product 820 info</h3>
<div>Test</div>
</div>
<!-- Tab01 End -->
<!-- Tab02 Start -->
<div data-role="collapsible" id="selection_product_info2_820">
<h3 class="display-none">product 820 info 2</h3>
<div>text 2</div>
</div>
<!-- Tab02 End -->
</div>
In order to make the button work, right now I need to add the event as follow in javascript by hard coding all product IDs. Is anybody know how I can rewrite the following scripts which makes the product id dynamically work and expand the relevant div under the product instead of hard coding the product id?
Remark: we are using jquery.mobile-1.3.2 and jquery-1.9.1.min.js
$("#expand_product_info_810") .on("click", function() {$("#selection_product_info_810").trigger("expand");})
$("#expand_product_info_820") .on("click", function() {$("#selection_product_info_820").trigger("expand");})
$("#expand_product_info2_810") .on("click", function() {$("#selection_product_info2_810").trigger("expand");})
$("#expand_product_info2_820") .on("click", function() {$("#selection_product_info2_820").trigger("expand");})