سؤال

I have a select box on my thymelaf page. I already have defined one attribute for it like:

th:attr="labelId='associateTSF' + ${mViewStat.index}"

Is there a way to set more than one? something like:

th:attr="labelId='associateTSF' + ${mViewStat.index}; missionGroup=${mView.missionGroup}"

I have already tried this with ; and with blank space, no success. All examples I have found are with single value.

Thanks!

هل كانت مفيدة؟

المحلول

Found it! And it works. It should be separated by comma.

HTML forbids repeated attributes, so that code is not correct. However, th:attr and data-th-attr allow you to specify several attributes separated by commas, like:

 <a href="#"     data-th-attr="data-groupid=${somevalue},
                  data-groupname=${someothervalue}">...</a>

found it on this discussion: https://github.com/thymeleaf/thymeleaf/issues/93

نصائح أخرى

This worked for me

th:attr="attrParam1=${attrVal1}, 
         width=${width != null ? width : null}, 
         height=${height != null ? height : null}"
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top