Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [JavaScript]bbcode editor i aktualizacja na bieżąco
kamilo818
post
Post #1





Grupa: Zarejestrowani
Postów: 250
Pomógł: 11
Dołączył: 20.01.2014

Ostrzeżenie: (0%)
-----


Chce osiągnąc efekt aktualizacji na bieżąco.

  1. $('input.btn2').click(function(){
  2. var b = $('#editor2').sceditor('instance').val();
  3. $('div.test2').html(b);
  4. });
  5.  
  6.  
  7. $(function() {
  8. $("#editor2").sceditor({
  9. style: "http://www.page4u.waw.pl/bb/minified/jquery.sceditor.default.min.css"
  10. });
  11. });
  12. $('#editor2').on('input', function() {
  13. var x = $('#editor2').sceditor('instance').val();
  14.  
  15. $('.test2').html(x);
  16. });
  17. <div>
  18. <div class="edit">
  19. <textarea id="editor2" ></textarea>
  20. </div>
  21.  
  22. <input type="button" class ="btn2" value="Zapisz"/>
  23.  
  24. <div class="test2" ></div>
  25. </div>


Jeśli odłacze edytor bbcode to działa. Ale w takim wypadku nie pobiera wartosci on('input')

Jakiś pomysł jak to zrobic?

edit:
Próbowałem tez AngularJs i tez nie działa'
  1. <div ng-app="">
  2. <div class="edit">
  3. <textarea id="editor2" ng-model="name"></textarea>
  4. </div>
  5.  
  6. <input type="button" class ="btn2" value="Zapisz"/>
  7.  
  8. <div class="test2" ng-bind="name"></div>
  9. </div>


Ten post edytował kamilo818 3.09.2014, 21:30:02
Go to the top of the page
+Quote Post
trueblue
post
Post #2





Grupa: Zarejestrowani
Postów: 6 806
Pomógł: 1828
Dołączył: 11.03.2014

Ostrzeżenie: (0%)
-----


Dlaczego nie czytasz dokumentacji?

http://www.sceditor.com/api/sceditor/keydown/
http://www.sceditor.com/api/sceditor/keypress/
http://www.sceditor.com/api/sceditor/keyup/
Go to the top of the page
+Quote Post
kamilo818
post
Post #3





Grupa: Zarejestrowani
Postów: 250
Pomógł: 11
Dołączył: 20.01.2014

Ostrzeżenie: (0%)
-----


Staram się czytać. To jakoś przegapiłem.
Dzięki.

edit:

  1. $('#editor2').sceditor('instance').keyDown(function(e) {
  2. alert('Key down event fired.');
  3. });


Konsola wyrzuca błąd

  1. Uncaught TypeError: Cannot read property 'keyDown' of undefined



edit2:

Zadziałało coś takiego:

  1. $(function() {
  2. var ctx = $(".sceditor-container iframe").contents();
  3. $('body', ctx).on('input', function() {
  4. var b = $('#editor2').sceditor('instance').val();
  5. $('div.test2').html(b);
  6. });
  7. });


Ale nadal jestem ciekaw czemu keyDown nie działa mi (IMG:style_emoticons/default/sad.gif)

Ten post edytował kamilo818 4.09.2014, 11:43:44
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 22.08.2025 - 23:25