Note that there are some explanatory texts on larger screens.

plurals
  1. PODefining objects when using Jaxer
    primarykey
    data
    text
    <p>I've been playing with <a href="https://github.com/aptana/Jaxer" rel="nofollow noreferrer">Jaxer</a> and while the concept is very cool I cannot figure out how to define objects that are available on both the client and the server. None of the examples I can find define objects at all.</p> <p><strong>I'd like to be able to define an object and specify which methods will be available on the server, which will be available on the client, and which will be available on the client but executed on the server (server-proxy).</strong> Can this be done without using three separate <code>&lt;script</code>> tags with different <code>runat</code> attributes? I would like to be able to define all of my methods in the same js file if possible, and it is not practical to define my objects inline in the html with three separate tags...</p> <p>Basically I'd like to be able to do this in one js file:</p> <pre><code>function Person(name) { this.name = name || 'default'; } Person.runat = 'both'; Person.clientStaticMethod = function () { log('client static method'); } Person.clientStaticMethod.runat = 'client'; Person.serverStaticMethod = function() { log('server static method'); } Person.serverStaticMethod.runat = 'server'; Person.proxyStaticMethod = function() { log('proxy static method'); } Person.proxyStaticMethod.runat = 'server-proxy'; Person.prototype.clientMethod = function() { log('client method'); }; Person.prototype.clientMethod.runat = 'client'; Person.prototype.serverMethod = function() { log('server method'); }; Person.prototype.serverMethod.runat = 'server'; Person.prototype.proxyMethod = function() { log('proxy method'); } Person.prototype.proxyMethod.runat = 'server-proxy'; </code></pre> <p>Also, assuming I was able to do that, how would I include it into html pages correctly?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload