Apuntes para RJS

Estos son trozos de código de RJS que pongo aquí porque creo que son muy interesantes y porque me va a ayudar el guardarlos aquí:

Como mostrar un mensaje de alerta al pulsar en un enlace, con indicador de funcionamiento y llamando a un servicio web:

En el cliente (rhtml):

<%= link_to_remote "Alert without RJS",
       :url => { :action => “alert_without_rjs” } -%>

En el servidor (rb):

  def alert_without_rjs
    render :text => "alert('Hello without RJS')",
         :content_type => "text/javascript"
  end

También se puede hacer renderizando una plantilla, con el mismo código rhtml:

En el servidor

  def alert_without_rjs
  end

Una plantilla: alert_without_rjs.rjs:

page.alert "Hello with RJS"

Todavía no hay comentarios

Enviar un comentario nuevo

El contenido de este campo se mantiene privado y no se mostrará públicamente.
  • Etiquetas HTML permitidas: <a> <blockquote> <br> <cite> <code> <dd> <div> <dl> <dt> <em> <h1> <h2> <h3> <h4> <h5> <h6> <hr> <img> <li> <ol> <p> <pre> <span> <strong> <swf> <table> <tbody> <td> <th> <tr> <ul>
    Allowed Style properties: background-color, background-image, border, border-bottom, border-bottom-color, border-bottom-style, border-bottom-width, border-color, border-left, border-left-color, border-left-style, border-left-width, border-right, border-right-color, border-right-style, border-right-width, border-spacing, border-style, border-top, border-top-color, border-top-style, border-top-width, border-width, color, direction, font, font-family, font-size, font-style, font-variant, font-weight, height, left, line-height, list-style-type, margin, margin-bottom, margin-left, margin-right, margin-top, padding, padding-bottom, padding-left, padding-right, padding-top, right, text-align, text-decoration, top, width
  • Syntax highlight code surrounded by the {syntaxhighlighter OPTIONS}...{/syntaxhighlighter} tags.
  • E-Mail addresses are hidden with reCAPTCHA Mailhide.

Más información sobre opciones de formato

CAPTCHA
Esta pregunta es para comprobar si eres un ser humano y evitar el envío automático desde sistemas de spam