English 中文(简体)
Timeout in a Couchapp list when using mustache
原标题:

I have a simple list view in which I (try to) use mutache to render the output of a list containing 5 results.

function(head, req) {
  var row,
      mustache = require("vendor/couchapp/lib/mustache.js"),
      template = "<li>{{project}} {{version}} {{description}}</li>";

   while(row = getRow()) {
    send(mustache.to_html(template,row));
   }
}

This results in a timeout :

[error] [<0.22977.0>] OS Process Error <0.22858.0> :: {os_process_error,"OS process timed out."}

when I try

function(head, req) {
  var row,
      template = "<li>{{project}} {{version}} {{description}}</li>";

   while(row = getRow()) {
     send("Hello");
   }
}

this nicely prints 5x Hello.

I narrowed it down to the require statement to load the template code.

Can anyone give me a clue where the timout is coming from?

------ SOLVED -------

The require call does not like the .js file extension of the filename of the code to refer to.

Changing it to :

function(head, req) {
  var row,
      mustache = require("vendor/couchapp/lib/mustache"),
      template = "<li>{{project}} {{version}} {{description}}</li>";

   while(row = getRow()) {
    send(mustache.to_html(template,row));
   }
}

fixed the problem.

最佳回答

The require function provided adds the .js extension so it should not be given in the parameter string.

问题回答

暂无回答




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签