I have nativescript app where in app.js is set:
application.run({
moduleName: "app-root/app-root",
context: {
param1: "A",
param2: "B",
param3: "C",
param4: "D"
}
});
This fires up app-root (Side drawer) but does not pass any params to it. Is this even possible to use this way?
I have push notifications implemented and when notification fires up app, it should send received params to "app-root" page. I've tried with appSettings but it's not best (speed) option.
Any suggestions? Thx
Thanks
Related
I have a short question.
Does inertia render asynch?
I realized, as soon I delete a DB - Entry, while I connect to new Nav-Link direct afterwards (Inertia.onStart)- which redirects me on another Page, the changes (onSuccess) wont be showed up.
Inertia.post('data-delete', {
id: this.meeeh.data[index].id,
}, {
preserveScroll: true,
onBefore: () => {
window.Toast.confirm('Delete?');
},
onStart: (visit) => {
window.Toast.load('Delete...');
},
onSuccess: (page) => {
return Promise.all([
window.Toast.success(page.props.toast),
/** Wont show after click another Link in Navbar */
])
},
onError: (errors) => {
window.Toast.error(errors);
}
});
How does it come, I have to wait until the process is Finished - otherwise my Page is not working correctly?
Not sure if I understand what you're looking for.
onSuccess runs immediately after the post request has finished AND in successful. It is completely separated from other links and it's purpose (if your returning a Promise from it) is to delay the execution of the onFinish handler.
From the docs:
It's also possible to return a promise from the onSuccess() and
onError() callbacks. This will delay the "finish" event until the
promise has resolved.
I also believe there's some problem in your code: Promise.all should receive an array os Promises and I'm pretty sure window.Toast.success(page.props.toast) isn't returning one, is it?
So... chances are that your Promise.all is never resolving.
I want to make a GET request to an api and the request in the server side looks like below, using AJAX
http://localhost:8000/api/?email=test#test.com
In other words, instead, instead of populating data to our ember model using the command, return this.store.query('testmodel',{ email: test#test.com }), I need replace this by a AJAX call in the ember controller
Please Help
thanks in advance
You can set up ajax as an ember service you can inject to your controller.
install the ember-ajax service:
ember install ember-ajax
Restart your server. Then in your controller you can inject the service:
import Ember from 'ember';
export default Ember.Controller.extend({
ajax: Ember.inject.service(),
actions: {
sendRequest() {
return this.get('ajax').request('/api', {
method: 'GET',
data: {
email: 'test#test.com'
}
});
}
}
});
With that done, just add a button that will fire the action or call the action when you need it in the controller.
I am developing an android application that includes gcm push notifications via ti.cloudpush module.
I would like to launch specific windows for certain type of push notifications.
Is theere any proper way to acieve this.
Following are my workouts.
CloudPush.addEventListener('callback', function(evt) {
alert("Notification received: " + evt.payload);
//-------------------launch code
var win=Ti.UI.createWindow({
url:'music.js',
exitOnClose:true,
});
});
i also tried by creating pending intent.It was also not failure.
thanks in advance
In the callback you'll have a payload sent back.
alert(evt.payload);
CloudPush.addEventListener('callback', function(evt) {
Ti.API.debug(evt.payload);
}
The payload is a JSON string of your data payload. Use JSON.parse to turn this in to an object you can use.
https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse
You can use this payload to base the check on what intent, window or action you would like to fire.
var payload = JSON.parse(evt.payload);
if (payload... ) {
// Do first option
} else {
// Do fallback option
}
Inside your callback eventEventLister from cloudPush once you have parsed the payload you could load something similar to this:
CloudPush.addEventListener('callback', function(evt) {
... Do payload check if statement from evt.payload...
// Or this could be a new window, alert, etc,
Titanium.Android.NotificationManager.notify(0,
Ti.Android.createNotification({
contentTitle : "title",
contentText : "text",
tickerText : "custom notification!",
contentIntent : Titanium.Android.createPendingIntent({
intent : Titanium.Android.createIntent({
url : 'foo.js'
})
})
})
);
});
If you want to switch out a different window, set the url object in the intent to a custom variable that is set depending on what the evt.payload is that's sent back.
eg
intent : Titanium.Android.createIntent({
url : presetWindowUrl
})
I have 2 APIs which I want to use simultaneously, API1 and API2.
API2 deliver news feeds to API1, while API1 handles all the content in a list form. This means that if any list in API1 is clicked on, it will it will retrieve the the news feeds from API2 using an ID that has been defined.
Who can help me out here? I am stuck. The screenshot of my code is here: http://i1159.photobucket.com/albums/p637/Apulo_Cosmas/2API.jpg
Thanks so much.
Per the Sencha documentation here (under Digging In): http://docs.sencha.com/touch/2-0/#!/guide/first_app
You need to add a listener and a detail panel to your configuration, using this code (reference to contentId is not needed, you just need to pull the description property -- which contains the content -- from the original feed):
detailCard: {
xtype: 'panel',
scrollable: true,
styleHtmlContent: true
},
listeners: {
itemtap: function(nestedList, list, index, element, post) {
this.getDetailCard().setHtml(post.get('description'));
}
}
It might be easier if you manually listen to your list (which is fetched from API 1) itemtap event.
In your controller, there's should be something like:
refs: {
bloglist: 'blog list'
},
control: {
bloglist: {
itemtap: 'fetchAPI2'
}
},
fetchAPI2: function (list,index,target,record){
id = record.get('contentId'); //this is your id for using API2.
Ext.data.JsonP.request({
scope: this,
url: API2_URL,
callbackKey: 'callback',
params: {your params for API2 here},
callback: function(success,result) {
// whatever you want to do here
}
});
}
Hy guy.
I really tried to do it work but all im getting is an "IO Error".
Here's the code...
$('#uploaded').uploadify({
'uploader': '/Scripts/EggScripts/Uploadify/uploadify.swf',
'cancelImg': '/Scripts/EggScripts/Uploadify/cancel.png',
'buttonText': 'Anexar',
'script':'Interaction/Upload',
'folder': '/uploads/',
'multi': true,
'auto': true
});
'
[AcceptVerbs( HttpVerbs.Post )]
public string Upload(HttpPostedFileBase file)
{}
The breakpoint Upload action is not even being reached. I'm not using any Authorize decoration.
Any sugestion?
If the Upload action requires authentication this might not work because Uploadify relies on Flash and cookies are not sent along with the request. Also replace all hardcoded urls in your script with ones generated by url helpers:
'uploader': '#Url.Content("~/Scripts/EggScripts/Uploadify/uploadify.swf")',
'cancelImg': '#Url.Content("~/Scripts/EggScripts/Uploadify/cancel.png")',
...
You can also subscribe for different event handlers to try to further debug:
$('#uploaded').uploadify({
...
onComplete : function() {
},
onOpen : function() {
},
onError : function (event, id, fileObj, errorObj) {
}
});
Another thing to try is to put a breakpoint in the Application_Error event in Global.asax to see if some exception is thrown during the execution of the request on the server.
Uploadify recommends all paths be rooted so perhaps rooting the script param will help?
'script':'/Interaction/Upload'