我想你誤解了這個網站的工作原理,責任不在於其他人告訴你如何做某事 - 你要求別人從他們的一天中抽出時間幫助你。
這就是說,快速瀏覽一下你鏈接的頁面,顯示你想要做的不僅是可能的,而且非常簡單,並且與bindString兼容。從示例代碼竊取該頁面:
// Call this function before calling gapi.drive.realtime.load
function registerCustomTypes()
{
var Book = function() { };
function initializeBook()
{
var model = gapi.drive.realtime.custom.getModel(this);
this.reviews = model.createList();
this.content = model.createString();
}
gapi.drive.realtime.custom.registerType(Book, 'Book');
Book.prototype.title = gapi.drive.realtime.custom.collaborativeField('title');
Book.prototype.author = gapi.drive.realtime.custom.collaborativeField('author');
Book.prototype.isbn = gapi.drive.realtime.custom.collaborativeField('isbn');
Book.prototype.isCheckedOut = gapi.drive.realtime.custom.collaborativeField('isCheckedOut');
Book.prototype.reviews = gapi.drive.realtime.custom.collaborativeField('reviews');
Book.prototype.content = gapi.drive.realtime.custom.collaborativeField('content');
gapi.drive.realtime.custom.setInitializer(Book, initializeBook);
}
和
// Pass this as the 2nd param to your gapi.drive.realtime.load call
function onDocLoaded(doc)
{
var docModel = doc.getModel();
var docRoot = docModel.getRoot();
setTimeout(function()
{
var book = docModel.create('Book');
book.title = 'Moby Dick';
book.author = 'Melville, Herman';
book.isbn = '978-1470178192';
book.isCheckedOut = false;
book.content.setText("Call me Ishmael. Some years ago - never mind how long precisely - having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world.");
docRoot.set('tbook', book);
debugger;
}, 0);
}
祝你好運,有樂趣的實時API - 這是一個很大的好玩。
這應該是可能的..你能準確地顯示你在做什麼,以及具體的錯誤信息? –
如果可能的話,告訴我如何去做。這似乎不可能。 –