I am working on a CMS system “tries” to support multilingual natively.
I have form fields like
<input name="title[en]" type="text">
and using a slugger plugin which works successfully when I select the input field:
$("input[name=title\\[en\\]]").stringToSlug({getPut: "input[name=url\\[en\\]]"});
Question is: My en,fr,de,es values comes from db. How can make a foreach loop to tell jquery it should write the same line for multiple language like:
$("input[name=title\\[en\\]]").stringToSlug({getPut: "input[name=url\\[en\\]]"});
$("input[name=title\\[fr\\]]").stringToSlug({getPut: "input[name=url\\[fr\\]]"});
$("input[name=title\\[de\\]]").stringToSlug({getPut: "input[name=url\\[de\\]]"});
$("input[name=title\\[es\\]]").stringToSlug({getPut: "input[name=url\\[es\\]]"});
This only involves a simple refactoring technique: make a loop. If you create an array of the languages you want to use, you can use the jQuery
.eachmethod to acheive this.If you are concerned about performance and don’t want the overhead involved in the
.eachmethod, you can use a traditionalforloop instead: