Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Dojo数据绑定_Javascript_Jquery_Parsing_Dojo - Fatal编程技术网

Javascript Dojo数据绑定

Javascript Dojo数据绑定,javascript,jquery,parsing,dojo,Javascript,Jquery,Parsing,Dojo,当应用程序加载时,我使用DojoUI构建了一个web应用程序,我调用parser.parse()来创建必要的小部件。我现在正试图从Ajax请求到UI进行数据绑定。我一直在看一个例子,但是我看到模型是在解析器之前设置的 我需要能够从函数中设置模型,并将其绑定到UI。 由于我第二次调用parser.parse(),因此出现以下错误: dojo/parser::parse() error Error: Tried to register widget with id==xxxx but that id

当应用程序加载时,我使用DojoUI构建了一个web应用程序,我调用
parser.parse()
来创建必要的小部件。我现在正试图从Ajax请求到UI进行数据绑定。我一直在看一个例子,但是我看到模型是在解析器之前设置的

我需要能够从函数中设置模型,并将其绑定到UI。 由于我第二次调用parser.parse(),因此出现以下错误:

dojo/parser::parse() error
Error: Tried to register widget with id==xxxx but that id is already registered
还有没有一种方法可以只解析bindData函数并避免这个错误

预成型绑定功能

var model;

function bindData(data){    
    require([       
        "dojo/Stateful",
        "dojo/parser"   


    ], function( Stateful, parser){     
        model = new Stateful(data); 

parser.parse();    
    });
}
执行查询按钮时调用的函数

if (getSelectedRadioButton('userOption') == 1){

      if (!dijit.byId("employeeNumberId").value){         
          var employeeNumberId = dijit.byId("employeeNumberId");
          dijit.showTooltip(
            employeeNumberId.get('missingMessage'),
            employeeNumberId.domNode
          );
          showNotificationDialog("okResponseNotificationDialog", 'Please Enter A Valid Employee Number Proceed', 'User Options');
          return false;

      }else{
          showNotificationDialog("okResponseNotificationDialog", 'Please Wait While We Retrive Your Data', 'User Options');

          dojo.xhrPost({
              url: getEmployeeData,
              postData: dojo.toJson({
                employeeNumber: EmployeeId
              }),
              handleAs: "text",
              headers: {
                "Content-Type": "application/json",
                "Accept": "application/json"
              },
              sync: true,
              load: function (data) {

                  data = ({First: "John", Last: "Doe", Email: "jdoe@example.com"});

                  bindData(data);                 

              },
              error: function (error) {

                  showNotificationDialog('okResponseNotificationDialog', 'Contact Your HELP DESK  : ' + error, 'Error');
                }

              });         
      }
  }
JSP

<s:textfield required="true" name="Employee.firstname"
  id="surname" placeholder="Your Firstname"
  trim="true"
  data-dojo-type="dijit/form/ValidationTextBox"
  missingMessage="Please Enter Your Firstname!"
  invalidMessage="Invalid Firstname!" title="(a) Firstname:"
  style="width: 20em;" data-dojo-props="value: at(model, 'First.name'), uppercase:true, regExp:'^[`a-zA-Z ]+(([\,\.-][`a-zA-Z ])?[`a-zA-Z ]*)*$'"/>

对,您不能调用parser.parse()两次。您可能应该使用EditModelRefController,而不是仅为模型使用有状态控制器,然后您应该能够使用虚拟数据对其进行初始设置,然后在可用时使用真实数据替换它。要查看替换模型的示例,可以查看以下内容:

我意识到我需要设置一个虚拟模型,然后使用setter设置它的属性。你能帮我解决这个问题吗