ckeditor可以更新数据库内容吗?(can ckeditor update database content?)
你能给我一种方法将ckeditor的内容保存到数据库吗?
我有0%的想法,如何使事情工作,这将是第一次使用一个。 我在谷歌搜索但它总是显示fckeditor(他们是一样的吗?)。 另外,我已经尝试了一些带有AJAX的代码,但仍然无法使其工作,因为它需要一些插件,我实际上并不理解它。
无论如何,我使用4.0版本的ckeditor,更喜欢PHP或javascript代码,因为我真的不知道AJAX。 这是我的试用代码:
<!DOCTYPE html> <!-- Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license --> <?php include('global.php'); ?> <html> <head> <script> var type = 'Admin'; <!-- editableContent --> window.onload = function (){ if(type=='Admin'){ document.getElementById('opener').contentEditable= true; document.getElementById('main').contentEditable= true; // We need to turn off the automatic editor creation first. CKEDITOR.disableAutoInline = true; var editor = CKEDITOR.inline( 'opener' ); var editor = CKEDITOR.inline( 'main' ); } else{ document.getElementById('opener').contentEditable= false; document.getElementById('main').contentEditable= false; } } function showHTML () { document.getElementById('textpad').textContent = textEditor.document.body.innerHTML; return; } </script> <title>Inline Editing by Code — CKEditor Sample</title> <meta charset="utf-8"> <script src="ckeditor/ckeditor.js"></script> <link href="ckeditor/samples/sample.css" rel="stylesheet"> <style> #editable { padding: 10px; float: left; } </style> </head> <body> <div id="opener"> <? $result= mysql_query ("SELECT * from text_tb WHERE categoryName='index'"); while($row = mysql_fetch_array($result)){ echo $row[1]; } ?> </div> <div id="main"> <? $result= mysql_query ("SELECT * from text_tb WHERE categoryName='about'"); while($row = mysql_fetch_array($result)){ echo $row[1]; } ?> </div> </body> </html>
非常感谢您的时间和帮助。
can you give me a way to save the contents of the ckeditor to the database?
i have 0% idea on how to make things work for this would be the first time to be use one. i've searched on google but it always shows the fckeditor(are they the same?). also, i've tried some codes with AJAX on it but still couldn't make it work because it requires some plugin and i don't actually understand it.
anyway, i'am using the 4.0 version of ckeditor and would prefer php or javascript code because i don't really know AJAX. here's my trial code:
<!DOCTYPE html> <!-- Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license --> <?php include('global.php'); ?> <html> <head> <script> var type = 'Admin'; <!-- editableContent --> window.onload = function (){ if(type=='Admin'){ document.getElementById('opener').contentEditable= true; document.getElementById('main').contentEditable= true; // We need to turn off the automatic editor creation first. CKEDITOR.disableAutoInline = true; var editor = CKEDITOR.inline( 'opener' ); var editor = CKEDITOR.inline( 'main' ); } else{ document.getElementById('opener').contentEditable= false; document.getElementById('main').contentEditable= false; } } function showHTML () { document.getElementById('textpad').textContent = textEditor.document.body.innerHTML; return; } </script> <title>Inline Editing by Code — CKEditor Sample</title> <meta charset="utf-8"> <script src="ckeditor/ckeditor.js"></script> <link href="ckeditor/samples/sample.css" rel="stylesheet"> <style> #editable { padding: 10px; float: left; } </style> </head> <body> <div id="opener"> <? $result= mysql_query ("SELECT * from text_tb WHERE categoryName='index'"); while($row = mysql_fetch_array($result)){ echo $row[1]; } ?> </div> <div id="main"> <? $result= mysql_query ("SELECT * from text_tb WHERE categoryName='about'"); while($row = mysql_fetch_array($result)){ echo $row[1]; } ?> </div> </body> </html>
thank you very much for your time and help.
原文:https://stackoverflow.com/questions/14005247
最满意答案
没有
TimeStamps stamps = realm.where(TimeStamps.class).findFirst();
这会在当前线程上获得
stamps
if(!timeStamps.getInfractionTimeStamps()。equalsIgnoreCase( stamps.getInfractionTimeStamps() ))
这会尝试访问不同线程上的
stamps
实例,因此您将收到IllegalStateException返回null;
即使它确实起作用,这条线也会使RxJava2抛出一个NullPointerException异常
.subscribeOn(Schedulers.newThread())
这可以很容易地被
Schedulers.io()
代替,所以它不会创建太多的线程(尽管当然你应该确保使用try(Realm realm = ...)
或者finally { realm.close() }
).subscribe(new Observer>(){
这是错误的,除非你“正确地实现了onSubscribe”,这是不应该的,这应该是
new DisposableObserver<List<Infraction>>()
。在这种情况下,您的Retrofit界面应该可能会公开
Single<T>
,因为完成后单身会自动取消订阅。
Single<TimeStamps> callTimeStamp = apiInterface.getTimeStamp(); callTimeStamp.flatMap((timeStamps) -> { try(Realm realm = Realm.getDefaultInstance()) { TimeStamps stamps = realm.where(TimeStamps.class).findFirst(); if(!timeStamps.getInfractionTimeStamps().equalsIgnoreCase( stamps.getInfractionTimeStamps())) return apiInterface.getInfractions(); else return Single.never(); } }).subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new DisposableObserver<List<Infraction>>() { @Override public void onNext(List<Infraction> infractions) { } @Override public void onError(Throwable e) { } @Override public void onComplete() { } });
No
TimeStamps stamps = realm.where(TimeStamps.class).findFirst();
This obtains
stamps
on the current threadif(!timeStamps.getInfractionTimeStamps().equalsIgnoreCase( stamps.getInfractionTimeStamps()))
This attempts to access that
stamps
instance on a different thread, so you'll get an IllegalStateExceptionreturn null;
Even if it did work, this line would make RxJava2 throw a NullPointerException
.subscribeOn(Schedulers.newThread())
This could easily be
Schedulers.io()
instead so that it wouldn't create too many threads (although then of course you should make sure you usetry(Realm realm = ...)
orfinally { realm.close() }
).subscribe(new Observer>() {
This is wrong unless you "properly implement onSubscribe" which is not expected at all, this should be
new DisposableObserver<List<Infraction>>()
.In which case your Retrofit interface should probably expose
Single<T>
, as singles automatically unsubscribe when done.
Single<TimeStamps> callTimeStamp = apiInterface.getTimeStamp(); callTimeStamp.flatMap((timeStamps) -> { try(Realm realm = Realm.getDefaultInstance()) { TimeStamps stamps = realm.where(TimeStamps.class).findFirst(); if(!timeStamps.getInfractionTimeStamps().equalsIgnoreCase( stamps.getInfractionTimeStamps())) return apiInterface.getInfractions(); else return Single.never(); } }).subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new DisposableObserver<List<Infraction>>() { @Override public void onNext(List<Infraction> infractions) { } @Override public void onError(Throwable e) { } @Override public void onComplete() { } });
相关问答
更多-
在改进2 RX中处理错误(Handle errors in Retrofit 2 RX)[2022-04-22]
由于您使用的是RxJava,因此在出现网络错误时会调用onError ,并且端点相关的错误是Response一部分。 如果出现错误,请检查throwable是否是HttpException的实例 public void onError(Throwable e) { if (e instanceof HttpException) { 如果检查结果为真,您的请求中有错误。 将throwable投射到HttpException ,并且访问是成员。 例如 ((HttpException) e).respo ... -
改进Rx Java请求(Retrofit Rx Java Requests)[2023-09-22]
没有 TimeStamps stamps = realm.where(TimeStamps.class).findFirst(); 这会在当前线程上获得stamps if(!timeStamps.getInfractionTimeStamps()。equalsIgnoreCase( stamps.getInfractionTimeStamps() )) 这会尝试访问不同线程上的stamps实例,因此您将收到IllegalStateException 返回null; 即使它确实起作用,这条线也会使RxJava ... -
return getauthenticationtoken.getToken().subscribeOn(Schedulers.io()); 但您也可以使用默认调度程序创建调用适配器,它可以是Schedulers.io()。 return new Retrofit.Builder() .addConverterFactory(SimpleXmlConverterFactory.create()) .baseUrl("http://thecatapi.co ...
-
RX:同步承诺(RX: Synchronizing promises)[2023-10-27]
你可以使用concatMap操作符 ,它只有在完成之前才会开始处理下一个项目。 下面是一个例子,其中events$以200ms的间隔出现,然后以不同的持续时间连续处理: const { Observable } = Rx; const fakeWriteRequest = data => { console.log('started working on: ', data); return Observable.of(data).delay(Math.random() * 2000); ... -
如何在Silverlight Webclient上执行Rx Observable(how to do Rx Observable on Silverlight Webclient)[2022-05-11]
在这里,这是在Rx中发出Web请求的最佳方式。 public IObservableMakeWebRequest( Uri uri, Dictionary headers = null, string content = null, int retries = 3, TimeSpan? timeout = null) { var request = Obse ... -
我以这种方式工作。 我仍然需要了解如何使用composit订阅。 RadioLiveInfoObservableService radioLiveInfoObservableService=ApiProvider.getInstance().getRadioObserverInfo(); radioLiveInfoObservableService.commits(Type.INTERVAL) .observeOn(AndroidSchedulers.mainThread()) ...
-
您可以使用Transformer来创建通用状态代码验证程序: class StatusCodeVerifierTransformer
implements Observable.Transformer , T> { @Override public Observable call(Observable > responseObservable) { return responseObservable.flatMap(n ... -
NoClassDefFoundError经常发生在构建工具和/或热交换在更改依赖关系后无法更新时。 尝试Build > Clean Project ,然后再次运行。 NoClassDefFoundError often happens when the build tools and/or hot-swapping fails to update after changing dependencies. Try a Build > Clean Project and then run again.
-
getNews() .flatMap { Observable.fromIterable(it.getTopicsList()) } //or Observable.from() if you use RxJava1 .flatMap({ getNewsImage(it) }, { topic, imageUrl -> topic.imageUrl = imageUrl return@flatMap topic ...
-
在RxJava中,您可以从常规Java执行程序创建自己的调度程序: ExecutorService exec= Executors.newFixedThreadPool(2); //2 Fixed threads Schedulers.from(exec); 因此,只需为每个资源创建一个具有有限数量线程的执行程序,并在访问资源时使用该特定调度程序。 有限数量的线程将限制并发调用的数量。 编辑: 显然我误解了这个问题。 如果调用是异步的,您可以尝试使用Rx的背压来管理它们。 以下是如何使用Rx管理此类调用的 ...