WinJS: cómo resolver un recurso global directamente dentro de una opción
Frecuentes
Visto 326 veces
1
Is there a way to evaluate a global resource using WinJS directly in my WinJS control options definition, not using data-win-res
attribute, because the specific option is a complex object?
Esto es lo que tengo:
<div id="CustomControl" data-win-control="My.Custom.NameSpace.Control" data-win-options="{
opt1: 123,
opt2: [
{ prop1: WinJS.Resources.getString('Global_Resource_String').value },
...
}">
</div>
The following attempt to evaluate the resource crashes with an error that the interpreter expects a bracket but instead saw a left parentheses. You can see why I cannot easily generate a setter for this option and data-win-res="{ winControl: {opt2[0].prop1: "Global_Resource_String"} }"
no funciona para mi
1 Respuestas
0
It turns out that inside the data-win-options
attribute no function evaluation can be performed and thus the issue with evaluating global resources. If I want to assign a complex option to a global resource I need to do the function evaluation in a global variable and then assign to it like this:
<script type="text/javascript">
var resource = WinJS.Resources.getString('Global_Resource_String').value;
</script>
<div id="CustomControl" data-win-control="My.Custom.NameSpace.Control" data-win-options="{
opt1: 123,
opt2: [
{ prop1: resource },
...
}">
</div>
Respondido el 13 de Septiembre de 12 a las 12:09
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas javascript microsoft-metro windows-runtime visual-studio-2012 winjs or haz tu propia pregunta.