Cufon and Jquery Magic Preview

蓝咒 提交于 2019-12-12 02:43:50

问题


Jquery Magic preview allows a user to enter in text and have it auto update (much like this "submission field" works with the preview loading below!). I would like the user to be able to enter in the text and then the Cufon font to take over what they've written (or just have it typed in cufon font).

$(function() {
$('form.example input:text').magicpreview('mp_'); 
});

Cufon.replace('p#mp_trythis1');

An example here: http://twmorton.com/magicpreviewjquery/


回答1:


Alright, a better example of what I need would be previewing a font, like at this website:

http://www.fontspace.com/mario-arturo/sahara

When you type in what you need, whatever script running the preview refreshes the preview to show you what you've typed.




回答2:


Here is a simplified version (without magicpreview):

The html part:

<h1>Cufon Test</h1>
<input id="in" type="text">
<div id="out"><h1>Start typing ...</h1></div>

The javascript part:

Cufon.replace('h1');
$('#in').keyup(function(){
    $('#out').html('<h1>'+$(this).val()+'</h1>');
    Cufon.replace('#out h1');
});

​See live example here

EDIT: you can see two alternative versions here implemented as jQuery plugins.

  • v1 updates @ 1000 ms after focus lost & only if dirty
  • v2 updates @ 1000 ms after the last keyup


来源:https://stackoverflow.com/questions/3937187/cufon-and-jquery-magic-preview

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!