当前位置: 首页>>代码示例>>Golang>>正文


Golang JQuery.Attr方法代码示例

本文整理汇总了Golang中github.com/gopherjs/jquery.JQuery.Attr方法的典型用法代码示例。如果您正苦于以下问题:Golang JQuery.Attr方法的具体用法?Golang JQuery.Attr怎么用?Golang JQuery.Attr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/gopherjs/jquery.JQuery的用法示例。


在下文中一共展示了JQuery.Attr方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: replace

func replace(t jquery.JQuery) {
	href := t.Attr("href")
	id := t.Attr("replace")

	if len(id) == 0 || len(href) == 0 {
		log.Printf("%s: replace fails id '%s' href '%s'", currentPath, id, href)
		return
	}

	if page, doc, _ := mySite.Match(href); page == nil {
		log.Printf("page not found %s", href)
	} else {
		idSelector := "#" + id
		elt := jq(idSelector)
		if elt.Length > 0 {
			currentPath = href

			bn := doc.BodyNodeById[id]
			elt.ReplaceWith(bn.Markup(doc))

			doc.AddBodyNodeEventListeners(document, bn)

			// Select again since we've just changed it.
			elt := jq(idSelector)

			jqBind(elt)
			elt.Call("foundation", "reflow")

			// Change displayed page path without reloading page.
			window.Get("history").Call("pushState", "object or string", "Title", href)
		}
	}
}
开发者ID:platinasystems,项目名称:weeb,代码行数:33,代码来源:js.go

示例2: getDrawerListener

func getDrawerListener(c jquery.JQuery) (d canvas.Drawer, l canvas.Listener) {
	id := c.Attr("id")
	page := mySite.PageByPath[currentPath]
	switch p := page.(type) {
	case canvas.Interface:
		var ok bool
		if d, ok = p.Drawer(id); !ok {
			log.Printf("%s: no canvas drawer for id '%s'", currentPath, id)
		}
		l, _ = p.Listener(id)
	default:
		log.Printf("%s: found canvas on page with no interface", currentPath)
	}
	return
}
开发者ID:platinasystems,项目名称:weeb,代码行数:15,代码来源:js.go

示例3: canvasDraw

func canvasDraw(c jquery.JQuery) {
	if c.Attr("width") == "" && c.Attr("height") == "" {
		// Determine height from aspect ratio and parent's width.
		aspect := 1.5 // 3 by 2 aspect ratio
		attr := c.Attr("aspect")
		if attr != "" {
			_, err := fmt.Sscanf(attr, "%f", &aspect)
			if err != nil {
				panic(err)
			}
		}

		parent := c.Parent()
		w := parent.Width()
		c.SetAttr("width", w)
		c.SetAttr("height", float64(w)/aspect)
	}

	d, _ := getDrawerListener(c)
	if d != nil {
		go d.Draw(canvasContext(c))
	}
}
开发者ID:platinasystems,项目名称:weeb,代码行数:23,代码来源:js.go


注:本文中的github.com/gopherjs/jquery.JQuery.Attr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。