jupiterjs / jquerymx Goto Github PK
View Code? Open in Web Editor NEWjQuery MVC Extensions. jQuery extensions that makes all the annoying stuff easier.
Home Page: http://javascriptmvc.com
jQuery MVC Extensions. jQuery extensions that makes all the annoying stuff easier.
Home Page: http://javascriptmvc.com
Retrieving a View from an inline template fails if that the script tag has a hyphen in the type.
<script type="text/x-template" id="my-view">
...
</script>
<script type="text/javascript">
var view = $.View('my-view', { ... });
</script>
Currently jsrender, the replacement for jQuery Tmpl, is using a type of text/x-jquery-tmpl
for its templates, though that is likely to change to something like text/x-jsrender
prior to the release.
The error seems to occur with this line in jquery.view.js:
suffix = el.type.match(/\/[\d\w]+$/)[0].replace(/^\//, '.');
Apparently the regular expression doesn't like the hyphen.
A simple fix would be:
suffix = el.type.replace('x-', '').match(/\/[\d\w]+$/)[0].replace(/^\//, '.');
While at the end of the day, no one is forcing a developer to prepend a x- on their template script types, it is the standard way of denoting a MIME type extension, i.e. a MIME type that is not registered with IANA, so it seems like it should be supported.
If you generate an App with a camelcased name like MyApp using:
$> js jquery\generate\app MyApp
All files are placed in the folder 'myapp'
But if you then generate some models like this:
$>js jquery\generate\model MyApp.Models.MyModel
these are placed in the folder 'my_app' which actually makes alot more sense.
Currently when a model instance is updated, all attributes are sent up. It would be very helpful to have a mechanism to only send up modified attributes.
given following code:
jQuery.Controller.extend('ExampleController',
/* @Static /
{
onDocument: true
},
/ @prototype */
{
ready: function() {
//not called
}
});
The ready event handler is not invoked.
In the docs you list out $.route.attr({type: 'pages', id: 5}, true)
for changing multiple properties.
http://javascriptmvc.com/docs.html#!jQuery.route
It should be $.route.attrs({type: 'pages', id: 5}, true)
test description
Is the naming convention with removing controllers from the name for the controller plugins still necessary for 3.2?
I saw that it was the cause of some confusion in the forums and with the plugin based application layout there won't be an official
controller folder anymore.
I have this fixture:
$.fixture("POST /days/{dayId}/time_slots.json", function(original, settings, headers) {
alert(days[original.data.dayId].date)
})
when the url posted is: /days/17/time_slots.json or /days/27/time_slots.json
original.data.dayId evaluates to 7
I can trace it back to the fixture.js line 430. In the _getData function over there the res variable also displays 7 as the result.
Javascriptmvc version: 3.2
Browser: Firefox
Looks like this plugin was either never finished, or left behind during the 3.0 updates. Its test cases fail and are not included in the main jquery/test/qunit.js list of tests.
I'm not entirely sure I need the functionality yet, but either this plugin should be updated or removed before 3.0.
in jmvc/plugins/console/console.html
l6 should be
<link type="text/css" href="http://jqueryui.com/latest/themes/base/jquery-ui.css" rel="stylesheet" />
When creating an instance of a view and the Ajax call to retrieve the template fails (404, 500, etc), the error callback function is calling the checkText function with an empty string parameter, resulting in a "There is no template or an empty template at..." exception being thrown:
error: function() {
checkText("", url);
callback(404);
}
The exception terminates the rendering of the view and the view promise is never rejected. There is no way to determine that the rendering of the view failed and no way to perform custom error handling for the broken view. If the template cannot be found, the view should be rejected, allowing the error to be captured via the .fail callback function on the view promise:
var viewPromise = $.View('badTempatePath', { id: '123' });
$.when(viewPromise)
.done(function(markup) {
//Do something with template markup
})
.fail(function(){
//Handle broken view with custom error markup
});
hi,
i am having trouble with using the jquery tmpl engine via the $.View call. consider the following call:
$.View("//test/views/test.tmpl",{heads:[{class: "h1", mes: "Ping"}, {class: "h2", mes: "Pong"}]})
if test.tmpl look like this
{{each heads}}
<h1>${mes}</h1>
{{/each}}
it returns correctly <h1>Ping</h1> <h1>Pong</h1>
if test tmpl looks like this:
{{each heads}}
<h1 class="${class}">${mes}</h1>
{{/each}}
undefined is returned whereas i would expect <h1 class="h1">Ping</h1> <h1 class="h2">Pong</h1>
I just checked out the latest version of jquerymx and tested in Firefox 6.0
Since formParams() returns {id: ""} from a form with a field
this breaks the formParams() and isNew() integration.
From Justin on: http://forum.javascriptmvc.com/topic/isnew-on-model-treats-blank-ids-as-if-an-id-exists-and-sends-save-calls-to-update
"Those two are made for each other. We can probably change it to ignore an empty string too. "
Looks like there is a problem with the jquery app generator. It works fine to generate an app in the root dir, but returns an error whenever used with with a subdir:
dev:~/mm/jmvc$ ./js jquery/generate/app company/app1
company/funcunit.html
company/qunit.html
org.mozilla.javascript.WrappedException: Wrapped java.io.FileNotFoundException: company/test/qunit/company/app1_test.js (No such file or directory) (steal/rhino/file.js#210)
at org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Context.java:1773)
at org.mozilla.javascript.MemberBox.newInstance(MemberBox.java:202)
at org.mozilla.javascript.NativeJavaClass.constructSpecific(NativeJavaClass.java:281)
at org.mozilla.javascript.NativeJavaClass.construct(NativeJavaClass.java:200)
at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:3377)
at script(steal/rhino/file.js:210)
at script(steal/generate/generate.js:14)
at script(steal/generate/generate.js:155)
at script(steal/rhino/file.js:275)
at script(steal/generate/generate.js:172)
at script(steal/rhino/file.js:275)
at script(steal/generate/generate.js:172)
at script(steal/rhino/file.js:275)
at script(steal/generate/generate.js:140)
at script(jquery/generate/app:19)
at script(steal/steal.js:697)
at script(steal/steal.js:1325)
at script.require(steal/steal.js:1255)
at script(steal/steal.js:1249)
at script(steal/steal.js:855)
at script.after_Ret(steal/steal.js:1632)
at script(steal/steal.js:1651)
at script(steal/steal.js:1702)
at script(steal/steal.js:1683)
at script(steal/steal.js:1661)
at script(steal/steal.js:1702)
at script(steal/steal.js:1683)
at script(steal/steal.js:1661)
at script(steal/steal.js:752)
at script.load_calling_loaded(steal/steal.js:856)
at script.require_continue_check(steal/steal.js:1260)
at script(steal/steal.js:1325)
at script.require(steal/steal.js:1255)
at script(steal/steal.js:1249)
at script(steal/steal.js:855)
at script.after_Ret(steal/steal.js:1632)
at script(steal/steal.js:838)
at script.load_calling_loaded(steal/steal.js:856)
at script.require_continue_check(steal/steal.js:1260)
at script(steal/rhino/rhino.js:13)
at script.require(steal/steal.js:1255)
at script(steal/steal.js:1249)
at script(steal/steal.js:855)
at script.after_Ret(steal/steal.js:1632)
at script(steal/steal.js:834)
at script(steal/steal.js:49)
at script(steal/steal.js:833)
at script(steal/steal.js:1534)
at script(steal/steal.js:1538)
at script.steal(steal/steal.js:409)
at script(jquery/generate/app:10)
at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2487)
at org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.java:178)
at org.mozilla.javascript.tools.shell.Main.evaluateScript(Main.java:564)
at org.mozilla.javascript.tools.shell.Main.processFileSecure(Main.java:486)
at org.mozilla.javascript.tools.shell.Main.processFile(Main.java:452)
at org.mozilla.javascript.tools.shell.Global.load(Global.java:244)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:161)
at org.mozilla.javascript.FunctionObject.call(FunctionObject.java:413)
at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:3330)
at script(:1)
at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2487)
at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:164)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:398)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3065)
at org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.java:175)
at org.mozilla.javascript.tools.shell.Main.evaluateScript(Main.java:564)
at org.mozilla.javascript.tools.shell.Main$IProxy.run(Main.java:122)
at org.mozilla.javascript.Context.call(Context.java:515)
at org.mozilla.javascript.ContextFactory.call(ContextFactory.java:507)
at org.mozilla.javascript.tools.shell.Main.processOptions(Main.java:293)
at org.mozilla.javascript.tools.shell.Main.exec(Main.java:170)
at org.mozilla.javascript.tools.shell.Main.main(Main.java:157)
Caused by: java.io.FileNotFoundException: company/test/qunit/company/app1_test.js (No such file or directory)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.(Unknown Source)
at java.io.FileOutputStream.(Unknown Source)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.mozilla.javascript.MemberBox.newInstance(MemberBox.java:194)
... 28 more
The file controller/view/view.js has a direct dependency on steal, even when pluginified.
Line 17 and 20 :
view = "//" + new steal.File('views/' + ...
I wanted to add a test for controller.view and deferreds but the original deferred tests in view/qunit.html seem to get stuck at test no 19
Running jquery/view: object of deferreds
already.
The new version of formParams() required to be called only on
element.formParams() called on other than element returns undefined.
// new code
if ( params ) {
return this.setParams( params );
} else if ( this.is("form") ) {
return this.getParams( convert );
}
// old code
if ( this[0].nodeName.toLowerCase() == 'form' && this[0].elements ) {
return jQuery(jQuery.makeArray(this[0].elements)).getParams(convert);
}
return jQuery("input[name], textarea[name], select[name]", this[0]).getParams(convert); // this condition is not covered
When I trigger an event with some arguments:
$(element).trigger("someEvent", args)
"someEvent" : function(el, ev, args) { ... }
works fine and the function receives the arguments
however when the default event fires
"default.someEvent" : function(el, ev, args) { ... }
args is undefined
I get an error when trying to create a EJS template in IE9.
The code is:
new $.EJS({text: '<div>a test</div>'})
The error says:
Can't get the value for the property 'js': the object is null or is not defined
You can test the code on the same IE console.
Hi,
I was looking through the Cookie.js code and found two methods jQuery.evalJSON
and jQuery.toJSON
. Looking through the jQuery docs these methods don't exist and I wasn't sure if jQueryMX was adding them or if you meant jQuery.parseJSON
?
I couldn't find any current information on them so I wanted to verify the usage before creating a pull request around the update.
https://github.com/jupiterjs/jquerymx/blob/master/dom/fixture/fixture.js#L35
Fixture can no longer be used on its own.
The method $.fn.model(m) does two things:
Unfortunately there is no convenient way to undo this. So if we bound a model to element we can't unbind it (and replace with other model).
I think that there should be a method like
drag.distance() is not a function.
When building the production version of an app, the compressor fails if there is any white space ("\n", "\t", etc) inside the .ejs templates:
/-----------------------------------------------/
jquery/lang/string/rsplit/rsplit.js
appname/list/views/init.ejs
appname/list/views/template.ejs
])));___v1ew.push(">
");___v1ew.push((jQ
timer error
function () {
_this.onreadystatechange();
}
TypeError: Cannot find function error in object Type: string, value: >, from: 435930, to: 435932.
/-----------------------------------------------/
// THIS WORKS:
<%for(var i = 0; i < this.length ; i++){%><li <%= this[i]%>><%== $.View('//appname/list/views/template.ejs', this[i] )%></li><%}%>
// THIS DOES NOT WORK:
<%for(var i = 0; i < this.length ; i++){%>
<li <%= this[i]%>>
<%== $.View('//appname/list/views/template.ejs', this[i] )%>
</li>
<%}%>
When you have the following code:
html:
<script type='text/ejs' id='tmp_1'><%= name %></script>
js:
var view = $.View('tmp_1', { name: 'Henry' });
the view is considered as a 'tmpl' type of view, current code doesn't look at the 'type' attribute.
Pull request follows.
The variable 'item' is not always defined when I run /documentjs/doc:
documentjs.js", line 359: uncaught JavaScript runtime exception: TypeError: Cannot read property "name" from undefined
I added a simple check to make sure it is defined, although there very well could be an underlying issue that is triggering this.
When 'item' is undefined, the 'parent' parameter is an object with the following properties:
name: jQuery.fn
children: jQuery.fn.controllers,jQuery.fn.controller,jQuery.fn.closest,jQuery.fn.compare,jQuery.fn.curStyles,jQuery.fn.outerWidth,jQuery.fn.innerWidth,jQuery.fn.outerHeight,jQuery.fn.innerHeight,jQuery.fn.formParams,jQuery.fn.within,jQuery.fn.withinBox,jQuery.fn.models,jQuery.fn.model,jQuery.fn.jquery.model.services,jQuery.fn.prepend,jQuery.fn.append,jQuery.fn.after,jQuery.fn.before,jQuery.fn.text,jQuery.fn.html,jQuery.fn.replaceWith
type: class
parent: steal/dev/dev.js
comment:
construct: blah
diff --git a/documentjs.js b/documentjs.js
index 971c23a..b6ed60a 100644
--- a/documentjs.js
+++ b/documentjs.js
@@ -356,8 +356,8 @@ steal( '//steal/generate/ejs',
},
// returns all recustive 'hard' children and one level of 'soft' children.
listedChildren: function( item, stealSelf, parent ) {
- var result = stealSelf ? [item.name] : [];
- if ( item.children && !this.shallowParent(item, parent) ) {
+ var result = stealSelf && item ? item.name : [];
+ if ( item && item.children && !this.shallowParent(item, parent) ) {
for ( var c = 0; c < item.children.length; c++ ) {
var child = docJS.objects[item.children[c]];
var adds = this.listedChildren(child, true, item);
Hi,
I am facing few issues while working with $.route functionality. (jquery/dom/route/route.js)
(1)while getting data from url and (2) while setting the url
WHILE GETTING DATA FROM URL: ($.route.data._data)
I have set the route rule as $.route(':/var1');
And my url consists of a base64 encoded value. For eg: 'suryapavan' is encoded to "c3VyeWFwYXZhbg=="
Say, url is http://localhost/test/#!/c3VyeWFwYXZhbg==
Now, the $.route.data._data is having the key 'var1' with value "c3VyeWFwYXZhbg" (instead of "c3VyeWFwYXZhbg==")
Why these characters are being stripped?
WHILE SETTING THE URL:
I have a
$.route rule as $ .route(":var1/:var2");
But in the URL, if any of the values (val1 or val2) is having special characters like ". , /= etc", its not showing up.
I mean, for eg: var1 is given as "aaaa" and var2 is given as "bbbb/cccc"
the url is comming up as "#!aaaa/bbbb" (cccc in var2 is missing).
[ expected result: '#!aaaa/bbbb%2Fcccc' ]
This problem exists even in that example "jquery/dom/route/route.html"
Hope you understand my problems!
There may be something wrong with the escaping in route.js
Could anyone please help me.
My project was stuck-up abruptly due to these errors! and it has stopped the project delivery :(
-Thanks!
When stealing two or more apps using
steal("folder/appname1", "folder/appname2");
Firefox returns a "v is undefined" error on Line 192:
function(){var x=I.hookups;I.hookups={};ga(this,x);return this};z.each(["prepend","append","after","before","text","html","replaceWith","val"],function(x,B){K(B)})});steal.loaded("jquery/view/view.js");steal("jquery/lang/string",function(z){z.String.rsplit=function(r,N){for(var R=N.exec(r),I=[],X;R!==null;){X=R.index;if(X!==0){I.push(r.substring(0,X));r=r.slice(X)}I.push(R[0]);r=r.slice(R[0].length);R=N.exec(r)}r!==""&&I.push(r);return I}});steal.loaded("jquery/lang/string/rsplit/rsplit.js");
And fails to load either of the apps. Commenting out the second app completely resolves the error.
Stripping the second app to its bare essentials causes different errors:
steal(
"folder/app/list",
"jquery/jquery.js",
function(){
$("#appname2").folder_featured_list();
})
steal(
"jquery/controller",
"jquery/view/ejs",
"jquery/controller/view"
)
.then(
function($){
$.Controller("Folder.Appname2.List",
{
defaults : {}
},
{
init : function(){
}
});
});
Which causes the error "z.Class is not a function" on the production file on Line 192 of Appname2:
q)},update:function(u){X(this.options,u);this._unbind();this.bind()},destroy:function(){if(this._destroyed)throw this.constructor.shortName+" controller already deleted";var u=this.constructor.pluginName||this.constructor._fullName;this._destroyed=true;this.element.removeClass(u);this._unbind();delete this._actions;delete this.element.data("controllers")[u];z(this).triggerHandler("destroyed");this.element=null},find:function(u){return this.element.find(u)},_set_called:true});var H=z.Controller.processors;
Please advise.
I'm trying to implement new "associations" method.
$.Model.extend("Contact",{
attributes : {
birthday : 'date',
tasks: "Task.models"
},
...
I ran jquery/model/pages/associations.html exemple but there's an error
this.model is not a function
problem is here : res.push(this.model(raw[i])); in model.js row 924.
Actually, in "default" convert function, construct variable references a function using $.String.getObject.
when construct is called, "this" references Window object and not the wanted object.
I think getObject (jquery/lang) should return a function in that way
... (jquery/lang line 40)
if( isContainer(current) ) {
ret = getNext(current, parts[i], add);
if( ret !== undefined ) {
if ( add === false ) {
delete current[parts[i]];
}
//return ret; //current return
//should return something like that
return function(val) {ret.call(current, val)};
}
...
I'm not sure of the closure side effect.
Maybe, the getObject function should return both object and function reference.
return [current, ret]
and let default converter manage the return value:
"default" : function(val, error, type){
var construct = $.String.getObject(type)
return construct ? construct[1].call(construct[0], val) : val;
}
It seems that defaluts do not inherit in inherited controllers in beta 2 of 3.2
$Controller.extend("Parent",
{
defaults: {some_option:"default_value"}
}
{
})
Parent.extend("Child",
{
}
{
init: function(){
//this.options.some_option == undefined
}
}).;
Getting the following on lates build:
command:
js jquery/generate/model cookbook.models.client
output:
cookbook/fixtures/clients.json.get
there is nothing in steal/generate/templates/scaffold/model
js: uncaught JavaScript runtime exception: TypeError: Cannot read
property "leng
th" from null
running on windows.
When I define e.g. $.route('zone/:id', {id: 1})
and the corresponding event listener $.route.bind('change', function() { /* ... */ })
I get strange redirects for certain routes:
#zone
is redirected to #!zone/undefined&one=
#!zone
is redirected to #!zone/undefined&zone=
#zone/1
is redirected to #!zone/undefined&one%2F1=
#!zone/1
is redirected to #!zone/
#!foobar
is redirected to #!zone/undefined&foobar=
#!zone/2
, #!zone/3
etc. work as expected.
I am using the stand-alone version of fixtures linked to from here:
http://jupiterjs.com/news/ajax-fixtures-plugin-for-jquery
In most cases, this is working as intended. For example:
$.ajax({
url : "../myJsonService",
dataType: "json",
fixture: "fixtures/fakeJsonService.json",
success : function(msg, textStatus, jqXHR) {
alert("Succeeded in loading data: " + textStatus + " " + errorThrown);
},
error : function(jqXHR, textStatus, errorThrown) {
alert("Failed to load data: " + textStatus + " " + errorThrown);
}
});
The fixture library is included, and everything works as expected.
However, if my ajax request points to an absolute URL rather than a relative path, it still seems to try to contact that url.
That is, if this line:
url : "../myJsonService",
is changed to:
url : "http://localhost:8080/myJsonService",
Then the service still gets called and, if the service is unavailable or throws an error, the "error" callback is called.. (Even if I have a valid fixture to take its place).
I would expect that if I have a fixture in place, and fixtures are enabled, then that fixture data would always be returned and the error function would never get called.
Hi,
I think there is a problem with proxy method. If I call proxy with multiple callback functions that return array back, that array is not properly passed to the next callback function. Here is short example that demonstrates the problem
test:function (){
this.run(['a','b','c'],this.proxy(["call1","call2"]));
},
run:function(arr,callback){
callback(arr);
},
call1:function(arr){
steal.dev.log("array length: "+arr.length);
return arr;
},
call2:function(arr){
steal.dev.log("array length: "+arr.length);
return arr;
},
If you run "test" function
The output is
steal.js INFO: array length: 3
steal.js INFO: array length: 1
Where I'd expect to see in both cases Length 3.
I tried to change in class.js
if ( f < length - 1 ) {
cur = !isArray(cur) || cur._use_call ? [cur] : cur
}
to
if ( f < length - 1 ) {
cur = [cur];
}
That fixed the issue and everything still seems to work.
Are there any special reasons for that !isArray(cur) || cur._use_call condition?
after all apply always wants to have a array of arguments.
This problem is also now causing Model to fail when using following config for ajax call
....
success: this.proxy(['models',success]),
...
I saw, since few days this line is comented out in model.js
//res._use_call = true; //so we don't call next function with all of these
Regards,
Dmytro
Here is the scenario:
Wanted namespace: CookBook
This is just an example, i want that for namespacing my different Apps, like MyApp1, MyApp2.
I would prefer to use a real namespace, so Cook.Book (or My.App1, My.App2 ...) but that would place the apps in a subdirectory, what steal/the generators can't handle apparently.
The generator scripts will translate that to cook_book, which is ok for me.
So i execute:
js jquery\generate\app cook_book
cook_book/cook_book.css
cook_book/cook_book.html
cook_book/cook_book.js
cook_book/controllers
...
(a name translation here would be fine too, so that i can say app CookBook)
now i want to add a model:
js jquery\generate\scaffold CookBook.Models.Recipe
! Error: folder cookbook/models does not exist!
it seems, that there a two different translations, one from app generation and the other from the model stuff ( app: CookBook -> coolbook, scaffold: CookBook -> cook_book) and the directory check uses the first.
if i create an empty directory cookbook/models and retry, it works.
js jquery\generate\scaffold CookBook.Models.Recipe
cook_book/controllers
cook_book/controllers/recipe_controller.js
cook_book/fixtures
cook_book/fixtures/recipes.json.get
...
As described, the workaround is to create that empty directory, but this will clutter up the directory just more (btw: i don't like it, that everything has to be in one directory, multi-level namespacing would be really cool)
Am I'm doing something terribly wrong or how am I supposed to use the naming patterns?
Using cook-book looks really ugly (ex. in a Model: Cook-Book.Models.Recipe? cook-book.Models.Recipe?)
I noticed that Model's standard methods, for instance, save(), return deferred.promise() object (it is makeRequest function in model.js file). Thus, it is not possible to cancel server request in progress using returned object.
As a proposed solution (thanks to Justin Meyer):
"Essentially, update / create / destroy should be returning the jqXHR object. Where update / create / destroyed is called by makeRequest:
https://github.com/jupiterjs/jquerymx/blob/master/model/model.js#L160
It should be getting back the jqXHR. It should make an abort method for its deferred call the jqXHR object's deferred."
Thank you,
Andrei
Largely based on this issue: http://code.google.com/p/javascriptmvc/issues/detail?id=91
A few snippets to clarify:
yourapp.js:
steal.plugins(
'jquery/controller',
'jquery/controller/view',
'jquery/view/ejs')
.views('init.ejs')
Loads init.ejs in the views folder into the production file of your app. An absolute path isn't given, because steal adds the absolute path itself. I've tried adding the absolute path as well, but it still gives the same problems. When using the view as follows in a controller:
some_controller.js:
$('div').append(this.view('//absolute/path/to/views/init'));
or
$('div').append('//absolute/path/to/views/init', {});
It succesfully loads the view in development mode. The view also gets added to the production build, as seen in the final production build:
production.js:
$.View.preload('absolute_path_to_views_init_ejs',jQuery.EJS(function(_CONTEXT,_VIEW) { try { with(_VIEW) { with (_CONTEXT) {var ___v1ew = [];___v1ew.push("<div id=\"somebox\" class=\"someblock\">\n");
___v1ew.push("</div>");; return ___v1ew.join('');}}}catch(e){e.lineNumber=null;throw e;} }));;
But somehow, the production build is still looking for init.ejs in the views folder. It isn't loading the cached view in production.js. I've also checked if $.View.cache was set to true and this seems to be the case.
Hi,
firstly, I wish you a good year and hope great fun and nice stuff with javascriptmvc project.
I've tried to use model/list/local and it doesn't work.
store function should use $.toJSON
store : function(name){
// go through and listen to instance updating
var ids = [], days = this.days;
this.each(function(i, inst){
window.localStorage[inst.identity()] = $.toJSON(instance.attrs());
ids.push(inst.identity());
});
window.localStorage[name] = $.toJSON({
type: this[0] && this[0].constructor.fullName,
ids: ids
});
return this;
}
At the opposite, retrieve should be something like this:
retrieve : function(name) {
// each also needs what they are referencd by ?
var props,
instances = [],
Class;
if (window.localStorage[name]) {
props = $.evalJSON(window.localStorage[ name ]);
}
props = props || {type : null, ids : []};
Class = props.type ? $.String.getObject(props.type) : null;
for ( var i = 0; i < props.ids.length; i++) {
var identity = props.ids[i],
instanceData = $.evalJSON(window.localStorage[ identity ]);
instances.push( new Class(instanceData) )
}
this.push.apply(this,instances);
return this;
}
I found a bug in the fixtures where the templated id's are truncated to the last digit.
Lp.Models.Principals.Teacher.findAll({ principal_id:1009, id : 105 })
$.fixture("GET /principals/{principal_id}/teachers/{id}.json", function(original, options, headers){
//original.data.principal_id == 9
//original.data.id == 5
})
Well, it seems that nested views do not render.
I've got my main view:
<% $.each(this, function(i, item){ %>
<% view(commonViewsPath + "items/item.ejs", item) %>
<% }) %>
and nestd view item.ejs:
It worked with JVMC 3.1
But now i've got notghing inside my main view (though item.ejs is download from server and definitely render is called - I've debuged it in jquery\view\ejs\ejs.js)
if I replace this call of the nested view with inline HTML:
<% $.each(this, function(i, item){ %>
I've got what it should be.
Given the following:
var options = {
cssNamespace: 'mynamespace-',
tagClass: 'mynamespace-tag',
tagSelector: 'a.mynamespace-tag'
}
If I create the templated event listeners "a.{tagClass} mouseover", and "{tagSelector} mouseover" the events are handled appropriately. But if I use "a.{cssNamespace}-tag mouseover", the event isn't handled.
I'm not sure if it's a Model#isDirty bug or Model#serialize() related.
Please have a look at the situation:
$.Model#backup
call. Model.User.attributes
static property had the following set of attributes at that moment:{ createdDate:"date", id:"string", modifiedDate: "date", name: "string" }
_backupStore
snapshot made with backup call.Class.attributes
during conversion.{ createdDate:"date", id:"string", modifiedDate: "date", name: "string", termsAcceptedOn: "date" // new attribute }
So what could be wrong:
Model#serialize()
uses Class.attributes
to serialize an object. Even if the object doesn't have an attribute, the attribute will be serialized as undefined
in case it's defined in Class.attributes
.Model#isDirty()
uses its own same
implementation which returns false in case the number of attributes on two objects is different. Absolutely the same objects, which were serialized on different points of time and have different number of undefined attributes.When I issue the following to generate index.html at a path which is case sensitive, I get an error, because it is looking for the path in all lower case. This is making it impossible to use in a case-sensitive environment like Mac or Linux.
./js jquery/generate/page /Library/WebServer/Documents/test/cookbook index.html
org.mozilla.javascript.WrappedException: Wrapped java.io.FileNotFoundException: /library/webserver/documents/test/cookbook/index.html (No such file or directory) (steal/rhino/file.js#217)
jQuery templates didn't work for until I replaced steal('jquery/view').then(function(){ on line 26 file jquery/view/tmpl/tmpl.js with steal('jquery/view').then(function(jQuery){
Extending model return Class with empty attributes.
$.Model.extend('X', {
attributes: {
x: 'string',
v: 'date'
}
},
{
});
X.extend('Y');
var x = new X(),
y = new Y();
console.log(x.Class.attributes, y.Class.attributes);
//x.Class.attributes => {x: 'string', v: 'date'}
//y.Class.attributes => {}
Similar to this question:
http://forum.javascriptmvc.com/topic/destroy-method-signature-on-model?reply=true&remember=604800&securemode=false
I have a nested route in a rails app and need additional attributes of the model instance to form it correctly. Currently only ID is passed into Destroy.
Last word from Justin on that thread "I need to think about how to make something like this a little easier."
Any more thoughts on this? Would like to be able to refer to all attributes on model in destroy().
$.Model validators can't be used if base class was created before loading validations.js.
Example:
[file x.js, steal('model.js')]: X extends $.Model. X doesn't use validations.
[file y.js, steal('x.js', 'validations.js')]: Y extends X. Y wants to use validations but can't do this because validations are injected into
Explanation of event flow:
3.2 beta 2:
in controller with more than one word name (for example my_more_than_one_word_controller)
this.view("view_name", params) tries to get view with path:
my_app/views/mymorethanoneword/view_name
and i suppose it should:
my_app/views/my_more_than_one_word/view_name
so underline character is missed.
Execute following steps:
./js jquery/generate/app some_test
./js jquery/generate/scaffold SomeTest.Models.Recipe
Then open some_test/test/funcunit/recipe_controller_test.js. Find the line 4
S.open("//some_test/sometest.html");
As you can see the name of common file is wrong. It should be:
S.open("//some_test/some_test.html");
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.