This Code Open the Invite Friend Dialog.
FB.ui({
method: 'apprequests',
message: 'My Great Request',
display: 'iframe'
});
I need to make these checkbox come checked?
Use the "to" parameter as mentioned in the documentation:
FB.ui({method: 'apprequests',
message: 'My Great Request',
to: user_ids,
});
The user will need to click the checkbox to check them.
Related
I'm looking at Ember to see whether it is suitable. One issue that came up is that we have many 'narrow' api calls - these calls return a list with the minimal data to create a list and then the user clicks on a link which goes to the detail view. Due to how link-to helper works, this will bypass the model method in the route. This question has the same issue: Transition from one route to another with a different model in Emberjs But I honestly don't understand the answer he provided. Specifically, he provides this code:
<a {{bindAttr href="somePropertyInYourModel"}}>{{someTextProperty}}</a>
and says:
The property somePropertyInYourModel is a property containing the url to the new page. If the url is in the ember routes it will be as if you where typing that address in the address bar and pressing enter, but without the full reload of the page.
I don't really understand what he's saying (my fault on this). I tried putting in <a {{bindAttr href="{{post}}"}}>{{someTextProperty}}</a> and <a {{bindAttr href="{{post}}"}}>{{someTextProperty}}</a>
but to no avail. Say I have this model:
Hex.Post = Ember.Object.extend({
id: null,
body: null,
isEnabled: null,
createdAt: null
});
How could I get this to work? What is he telling us to do?
thx for help, ember looks really cool but has a lot to know
edit #1
Here's the whole Router list. I want to have a posts view and when the user clicks, it goes to the post view which will be populated to the right. The problem is that the link-to bypasses the model so we really need to reload the model at that point. This would allow us to repurpose much of our existing api. Thx for help
Hex.Router.map(function() {
// put your routes here
this.resource('index', { path: '/' });
this.resource('users', { path: 'users' });
this.resource('loginslogouts', { path: 'loginslogouts' });
this.resource('locations', { path: 'locations' });
this.resource('flaggedcontent', { path: 'flaggedcontent' });
this.resource('posts', function(){
this.resource('post', { path: ':post_id' });
});
this.resource('comments', { path: 'comments' });
});
ahhh, send the id instead of the model, that will retrigger the model hook. Sending a model to the hook makes ember think you have the model, sending an id tells ember to hit the model hook with that id.
{{#link-to 'post' post.id}}{{post.name}}{{/link-to}}
I have implemented the Facebook 'Like Button' by using
fb:like
and I successfully managed to implement logic for the 'Like' event by using
FB.Event.subscribe('edge.create', function(response) {
//do something
});
and now when the user clicks the Like button a bubble box appears with a text box with default text 'Add a comment' and two buttons - 'Post to Facebook' and 'Close'.
I want to catch the event that is triggered by clicking the 'Post to Facebook' button.
I tried to use the following:
FB.Event.subscribe('comment.create', function(response) {
//do something
});
but it doesn't seem to work.
Can you tell me if there's another event that I should listen to or is this 'comment.create' the right one and I'm just not implementing it correctly?
Thanks
I would like to change emberjs's onEvent which is the trigger to perform the associated view action. There seems to be just 2 options for onEvent: the default enter, and keypress. I'd like to know if I can have other options as well, such as focusOut.
Small question
But first, I couldn't even get the non-default option to work:
Myapp.TextField = Ember.TextField.extend({
onEvent: 'keypress'
});
The text field didn't respond to key presses, but continued to respond to enter.
Actual question
How can we let ember.js text field respond to other onEvents to trigger the action specified in the view. This is something I'm expecting:
HBS:
<script type="text/x-handlebars" id="themodel">
{{view Myapp.TextField action="targetAction" valueBinding="myText"}}
</script>
JS view:
Myapp.TextField = Ember.TextField.extend({
// is this possible?
onEvent: 'focusOut'
});
JS controller:
Myapp.ThemodelController = Ember.ArrayController.extend({
targetAction: function(){
var usertext = this.get('myText');
// do stuff with the usertext ...
}
});
A workaround solution for the "Actual question"
This is a work-around as it doesn't modify onEvent, but directly lets focusOut trigger the targetAction:
JS view:
Myapp.TextField = Ember.TextField.extend({
focusOut: function(){
this.get('controller').set('myText', this.get('value')).targetAction();
}
});
But I really don't like this cumbersome implementation, so please let me know if there is a way to utilize onEvent with focusOut. Thanks.
I experienced something similar to your "small problem", only instead of the text field only responding to enter, it would respond to neither keypresses nor enter.
The solution lies within mavilein's answer to this question - the word "keypress" must be in camelCase, i.e "keyPress". This applies whether it is used as a property name when extending the Ember.TextField class, as you had originally attempted, or as an attribute on the actual view element as Mike had suggested. I tried it both ways. Hope this helps.
But first, I couldn't even get the non-default option to work
Strange. There is a test for exactly this behavior. Suggest having a look and see what's different in your use case.
How can we let ember.js text field respond to other onEvents to trigger the action specified in the view.
Following the same pattern used in Ember.TextField's insertNewLine fx
Myapp.TextField = Ember.TextField.extend({
onEvent: 'focusOut',
focusOut: function() {
sendAction('focusOut', this, event);
}
});
UPDATE: This is outdated, my blog is not Ember-based anymore. Basically, my question is simple. I added a record with createRecord(). I can see the didCreate event fired, but I don't know how to make ember load and display what I have just created. This case is about adding a comment to an post -- that is what I want to see instantly.
UPDATE: I have no jsfiddle, but I can show off the live app/site I am talking about is my own blog, here: http://eduardmoldovan.com/
The templates are at the bottom of the page, the javascript is here: http://eduardmoldovan.com/static/eduardmoldovan.com/javascripts/ngin.js
You can manually add your new record to array of records from the didCreate hook:
var newRecord = transaction.createRecord(Ngin.Comment, {
articleUrl: articleUrl,
name: name,
url: url,
email: email,
body: body,
secret: secret
});
newRecord.one('didCreate', this, function () {
this.get('comments').pushObject(newRecord);
});
transaction.commit();
Or, if you want to reload from server, use the reload method:
controller.get("comments").reload();
Edit
After examining sourcecode I found an update method in class RecordArray. It seems to be the right one.
Assuming you have used commit() to save the comment, something like this should work:
{{#each comment in post.comments}}
{{comment.text}}
{{/each}}
The following is neither efficient nor the best method but it will notify the view. And will try to find a better method. Im sure theres an update method and one that notifies the view. Cannot find it immediately.
template
<script type="text/x-handlebars" id="posts">
<button {{action 'newObject'}} ></button>
controller
App.PostsController = Ember.ArrayController.extend
actions: {
newObject: function() {
this.store.createRecord('post', {id: xxxx, title: 'Default title'});
var all = this.store.filter('post', function(post) {
return post; // return each object
}); //This filter will include the new post record
this.set('model', all); // set will notify the view of a mutated array
}
},
I've struggled with this for hours... new to creating graph actions... why doesn't our approved graph action work? We expect that when a user clicks the "Click Here!" button that it will show that they've scheduled a blood donation on their timeline. We have a form button coded precisely as outlined in the FB tutorial, and it's on a page tab we've added to a page, but nothing happens when you click the "Click Here!" button.
The page tab in question -> http://www.facebook.com/cityofhope.donateblood/app_323470837712150
Here's the code:
<script type="text/javascript">
function postSchedule()
{
FB.api(
'/me/cohblooddonor:schedule',
'post',
{ blood_donation: 'http://www.cityofhope.org/giving/Documents/blood-donor.html' },
function(response) {
if (!response || response.error) {
alert('Error occured');
} else {
alert('You've shared with your friends! Action ID: ' + response.id);
}
});
}
</script>
And the button:
<form>
<input type="button" value="Click here!" onclick="postSchedule()" />
</form>
Any help is appreciated! I've been going at this for hours. Is it an authentication issue? thanks in advance!
You've got a syntax error due to mismatched quotes on line 58 of your source: 'You've ...'
You could escape the literal apostrophe with a backslash, or change "You've" to "You have".
You also have a few other errors on the page. Check these out using the Javascript console on a modern browser.